title: nodejs express application won't return json array
body: <p>I have the following express node.js app. It's using the 'redis' npm package.</p>
  
  <pre><code>app.get("/test",function(req,res){
      var data = [];
      client.HGETALL("receipts",function(err,obj){
          for(var id in obj){
              data.push(JSON.parse(obj[id]));
          }
      });
      console.log(data);
      res.json(data);
  });
  
  app.listen(3000);
  </code></pre>
  
  <p>The code run's without errors; however, the <code>data</code> variable is <code>[]</code> when it's returned to the browser.
  <img src="https://i.stack.imgur.com/d0hGR.png" alt="browser"></p>
  
  <p>The strange part is that when I run the same redis commands from the command line, the array is populated. </p>
  
  <p><img src="https://i.stack.imgur.com/1OAmw.png" alt="enter image description here"> </p>
  
  <p>Can anyone tell me what's going on here?</p>