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?
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 statements.data variable.
   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?
What I need is that another variable results gets the statements.data from that DB request and the script continues.
How would I need to rewrite this code in order to do that?
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.
Thank you and sorry if this question is irritating in my inability to solve such a simple problem.
 
     
     
    