title: Issues with asynchronous behavior with NodeJS and Neo4j
body: <p>I'm a self taught novice programmer working on a simple web application that uses Angular.js, Node.js, and the graph database neo4j. Right now I'm trying to get a a very basic query to execute and return data to the client. Upon execution I get an error which closes the server.</p>
  
  <p>The following function is executed upon receiving a get request:</p>
  
  <pre><code>exports.test = function (req, res) {
  var neo4j = require('neo4j');
  var db = new neo4j.GraphDatabase('http://localhost:7474');
  var query = [
      'MATCH n',
      'RETURN n.name, n, labels(n)'
  ];
  db.query(query, function (err, results) {
      if (err) {throw err};
      var data = results.map(function(result) {
              return result;
      });
      res.send(data)
  }
  )};
  </code></pre>
  
  <p>I get the following error in the console log: java.lang.ClassCastException: java.util.ArrayList cannot be cast to java.lang.String</p>
  
  <p>(I can provide the entire log if it would prove useful)</p>
  
  <p>I would be extremely grateful for any insights.</p>