var result = [];var getInformationFromDB = function() {
mysql.connection.query('SELECT * FROM role', function(err, res, fields)
{
if (err) throw err;
if(res.length){
for(var i = 0; i<res.length; i++ ){
result.push(res[i]);
}
}
console.log("Inside npm");
console.log(result);
return result;
});
);
console.log("Outside npm");
console.log(result);
console.log("Call Function");
console.log(getInformationFromDB());
Output:
Outside npm
[]
Call Function
[]
Inside npm
[{Row1}, {Row2}]
Please suggest me assign value to outside variable??
--
Job board: http://jobs.nodejs.org/
New group rules:
https://gist.github.com/othiym23/9886289#file-moderation-policy-md
Old group rules:
https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines
---
You received this message because you are subscribed to the Google Groups
"nodejs" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/nodejs/1029dd89-35ba-40d7-a68a-c6193ec7bf0e%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.