Iterate save in Node.JS across an array
<p>I couldn't use a simple for loop because request.save is a function. So I tried forEach. It works perfectly! Until I add in the request.save part and I get the following error message that breaks my app.</p>

<p>Error: Can't set headers after they are sent.</p>

<pre><code>exports.submit = function (req, res) {


  Person.find({
      cellPhone: req.body.phone
  }).exec(function (err, people) {
      people.forEach(saveRequest);
  }

  function saveRequest(item, index) {

       var request = new Requests();
       request.start = req.body.start.value;
       request.finish = req.body.finish.value;
       request.phone = req.body.phone;
       request.offDay = req.body.date;

       request.user = people[index]._id;
       request.name = people[index].name;
       request.group = people[index].group;

       request.save(function (err) {
          if (err) {
             console.log('request.save');
             return res.status(400);
           } else {
             // Remove sensitive data before login
             //user.password = undefined;
             //user.salt = undefined;
             console.log(request);
             res.json(request);
           }
       });
  }
});
</code></pre>