I have a function in NodeJs
function ga_data(view, callback) {
overview = {orgaincCount:12,sessionsCount:3,newUserCount:4,sessionArray:session};
callback(1, overview);
}
Calling a fucntion
ga_data(view, function(err, result) {
if (err == 0) {
jsonString = {err : 1, result : []}
} else {
// res.send({status: 1, message: "Success",overview: result});
jsonString = {err : 0, result : result}
}
});
Now I want to access the callback result outside the callback function i.e.
ga_data(view, function(err, result) {
if (err == 0) {
jsonString = {err : 1, result : result};
} else {
jsonString = {err : 0, result : result};
}
});
console.log(jsonString);