title: Correct query using Mongoose, but array is always empty after forEach. Nodejs/MongoDB
body: <p>I want to return an array of names after a forEach inside an asynchronous method. Both the for each and the res.send are inside the Asyn. Method. The forEach works perfectly, but I always get an empty array.</p>
  
  <p>This is  my request in the website side: </p>
  
  <pre><code>function retrieveCharity(){
      $.ajax({
          type:"GET",
          url: "http://xxx.xxx.x.xx:9000/charity",
          success: function(data){
               data.charities.forEach(function(charityName){
                   $(".charity-ul").append("&lt;li&gt;"+charityName+"&lt;/li&gt;");
               })
          }
      })
  }
  </code></pre>
  
  <p>This is my router.get listener in the NodeJs side:</p>
  
  <pre><code>router.get('/', function (req, res){
     log.d("Entrou no method post - Charity"); 
     teamModel.find({},function(err,charities){
      var charityMap = {};
          if(err){
              console.log("Err in retrieving Charity")
              log.d("Err in retrieving")
              res.send({
                  "status":"error"
              })
          }else{
              charities.forEach(function(charity){
                      charityMap[charity._id]= charity.teamName;
              console.log("Print here the name of the charities I have,PLEASE" + charity.teamName);
                      log.d("foEach - data",charity);
              })
          res.send({
                "charities": charityMap
          })
          }
     })//end of findCahrity
  
  });
  </code></pre>
  
  <p>All the log.d and the information I ask to be printed inside them is correct, and they are printed. The problem is that the array I return is always empty, but both(forEach) and res.send are inside the asynchronous method. </p>
  
  <p>I always get this in post man:</p>
  
  <pre><code>{
  charities: { }
  } 
  </code></pre>
  
  <p>and the console always says :</p>
  
  <pre><code>Uncaught TypeError: undefined is not a function 
  </code></pre>
  
  <p>this line :</p>
  
  <pre><code> data.charities.forEach(function(charityName){
  </code></pre>
  
  <p>Can someone help me please. What am I doing wrong?</p>
  
  <p>Thanks in advance. </p>