How to return the value out side of the query function nodjs

Apr 19 2019 2:43 AM
I am trying to get the value from mysql using node.js. Now i want to that value display out side of the query function
 
I am trying this code :
 
var someVar=[];
con.query('SELECT Mobiles from Salestb' , function (err,rows,callback) {
if(err) {
throw err;
} else {
setValue(rows[0].Mobiles);
}
});
function setValue(value) {
someVar = value;
console.log(someVar);
}
console.log(someVar);
 
But it shows Null Value

Answers (1)