How to hold my response in nodejs until the end of my loop
<p>My code is as follows :</p>

<pre><code>myinsts.forEach(function (myinstId) {
Organization.getOrgById(myinstId,function (err,insts)
{
   res.json(insts);
})
});
</code></pre>

<p>I'm usng Node.js and I'm getting the error "Can't set headers after they are sent" , Obviously my server sends first iteration , how can I make it hold until I get the whole data </p>