Sunday 28 May 2017

Using a variable outside of a function in node.js [duplicate]

I am unable to use the variable "name" outside of this function. I can use this further down the code if I nest the rest of the code in the same function.
var name;

controller.storage.users.get(message.user, function(err, member) {
name = member.real_name
});

console.log(name)

Thanks.



via Brad Osborne

No comments:

Post a Comment