title: when i set the token in header in angularjs generating error in nodejs server?
body: <p>Error is:</p>
  
  <pre><code> Possibly unhandled Error: Can't set headers after they are sent.
      at ServerResponse.OutgoingMessage.setHeader (_http_outgoing.js:344:11)
      at ServerResponse.res.set.res.header
  </code></pre>
  
  <p>1.all nodejs services working fine before set the token in header.</p>
  
  <p>2.after set the token in header in angularjs creating that error in nodejs server.</p>
  
  <p>my angularjs code is :</p>
  
  <pre><code>menu.factory('allServs', function ($q, $http,$cookieStore) {
  propDetails:function (property_id) {
  
              var req = {
                  method: 'GET',
                  url: '/v1/xxxxxxx/'+xxxxxxx
                }
  
              if($cookieStore.get('userDetails')){
                  req.headers = {
                      "authorization": $cookieStore.get('userDetails').token
                  }
              }
              var deferred = $q.defer(),
                  httpPromise = $http(req);
              httpPromise.then(function (response) {
                  alert("response"+JSON.stringify(response));
                  deferred.resolve(response);
              }, function (error) {
                  alert("error"+JSON.stringify(error));
                  console.error(error);
              });
              return deferred.promise;
          }
  }
  </code></pre>
  
  <p>3.In nodejs ,webservice token is getting ,decoding is fine and getting the response details but the problem is last line  at the time of return json data.</p>
  
  <pre><code> app.get('/v1/xxxxxxx/:xxxxx',middlewares.requireLogin,function(req, res) {
  
      core.property.getProjectGroup(options, function (result) {
  
         return res.send({
                       result:result
                       });
                   });
  
      });
  </code></pre>
  
  <ol>
  <li>middlewares.requireLogin(token verify process) is working fine.</li>
  <li><p>I solved that error by using this line  res.status(200).send().In that process in client its showing success code is 400.</p></li>
  <li><p>so how can i solve that one. i want to get the data and status code as 200</p></li>
  </ol>