title: node js redis loop through each hash key value
body: <p>I am very new to redis &amp; node and at the moment I am trying to loop through some test hash keys that i have created and print out to screen the results. Here is the result I expect to see:</p>
  
  <pre><code>{ "aaData": [['Tim Osbourne'],['Joe Bloggs'],['John Doe'],['Perry Coke'],['Will Holmes'],['Steven Smith']}
  </code></pre>
  
  <p>but instead I get this result:</p>
  
  <pre><code>{ "aaData": [[],[],[],[],[],[],]}'Tim Osbourne','Joe Bloggs','John Doe','Perry Coke','Will Holmes','Steven Smith',
  </code></pre>
  
  <p>Here is my code:</p>
  
  <pre>
  
      app = require('../app');
      var redis = require("redis"),
      client = redis.createClient();
      routes = require('./');
      var key_types = '';
  
      client.keys("*", function (err, all_keys) {
          key_types += '{ "aaData": [';
  
          all_keys.forEach(function (key, pos) { // use second arg of forEach to get pos      
              key_types += "[";
  
              client.hmget([key, 'Owner of space'], function(err, field_val){
                  key_types = key_types + "'" + field_val + "',";
              });
  
              key_types += "],";
          });
  
          key_types += "]}";               
      });
  
      app.get('/table_data', function(req, res){
          res.render('table_data', { keys: key_types});
      });
  
  </pre>