title: How to receive a value from this JavaScript function?
body: <p>I know it's quite a typical question and I should look into callback functions, but as much as I've tried, I couldn't solve this one. Maybe you can help?</p>
  
  <p>The problem is very simple. At a certain point of my code I've got the following function that queries Neo4J database (through node.js node-neo4j library) and gets the results into <code>statements.data</code> variable.</p>
  
  <pre><code>   dbneo.cypherQuery(rangeQuery, function(err, statements){
  
              if(err) {
                  err.type = 'neo4j';
                  return fn(err);
               }
  
              console.log(statements);
  
              fn(null,statements.data);
  
       });
  
       var results = statements.data; // THIS DOESN'T WORK! HOW TO CHANGE IT?
  </code></pre>
  
  <p>What I need is that another variable <code>results</code> gets the <code>statements.data</code> from that DB request and the script continues.</p>
  
  <p>How would I need to rewrite this code in order to do that?</p>
  
  <p>I'm not very familiar with JavaScript, so I tried different syntax but it didn't work.
  For example, when I wrap the dbneo.cypherQuery function into another function and call its results, I still can't pass the value I need to the parameter.</p>
  
  <p>Thank you and sorry if this question is irritating in my inability to solve such a simple problem. </p>