title: Loop through array of id's and return documents which match with Mongoose
body: <p>I currently have an array which looks as follows (all id's are the same for testing purposes):
  <a href="https://i.stack.imgur.com/c4WoV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/c4WoV.png" alt="enter image description here"></a></p>
  
  <p>What I need to do is loop through this array and return the user associated with these Id's but cant seem to get it working.</p>
  
  <pre><code> $.ajax({
       url: "/findUsers",
       type: "POST",
       dataType: "json",
       data: {
          array:array
       },
       success: function (data) {
  
       }
     })
  </code></pre>
  
  <p>post request:</p>
  
  <pre><code>app.post('/findUsers', function(req, res){
      var array = req.body;
      console.log(array);
      for(var i = 0; i &lt; array.length; i++) {
  
        User.find({'_id': array[i]}).exec(function(err, docs){
                   console.log(docs);
              });
           }
          });
  </code></pre>
  
  <p>I can log the array server side but nothing is returned to me?</p>
  
  <p>Logging array in console:
  <a href="https://i.stack.imgur.com/lXPYJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lXPYJ.png" alt="enter image description here"></a></p>