I'm trying to use the value of a global variable outside of a function which updates it. But, processing this way, I dont't get the expected result as the below code explains it.
var res = {};
client.fetchOne(query, function(err, response) {
res = response;
console.log(res);
}); //the expected result is displayed here
console.log(res); //{} is displayed here
What's wrong with this? Do I need to use closures? Any brilliant idea, please?