// accept a callback function to execute after getting results...
function searchCoords(callback){
var result = result;
connection.query('SELECT * FROM monitoring', function(err, result){
if(err){
console.log(err);
}
// run the callback function, passing the results...
callback({result: result});
});
}
// call like this...
searchCoords(function(resultsObject){
console.log(resultsObject.result)
});
That's my code, I have an anonymous nested function which returns a variable to the outside by using a callback function. However, the variable returned (result) is an array which i need to use with googlemaps api in node.js. how can i turn this:
searchCoords(function(resultsObject){
console.log(resultsObject.result)
});
into a variable that will contain the whole array so i can call it from themarkers option in the api