title: Can't set headers after they are sent. in express js
body: <p>I am using express package of nodejs and I have written this function to send response for any generic API. Although it keeps giving error and I can't figure out why. status function sets response status so I don't know why this should happen</p>
  
  <pre><code>function ResponseHandler(response, respObj, resData) {
  
    var resp = {
      "message" : respObj.message,
      "data" : resData
    }
  
    response.status(respObj.code);
    response.json(resp);
  }
  </code></pre>