Long story short, im newish to NodeJS and im trying to change a variable after a function has been executed, however I cant return a result like I thought I could.
app.get('/:steamid', function(req, res) {
var steamID;
var steamAvatarUrl;
var steamRegisterDate;
steamAPI.ResolveVanityURL(req.params.steamid, function(err, res) {
console.log('Steam64: ' + res); // <- this prints out my result
steamID = res;
});
steamAPI.getAvatarUrl(req.params.steamid, function(err, res) {
console.log('Avatar URL: ' + res); // <- this prints out my result
steamAvatarUrl = res;
});
steamAPI.memberSince(req.params.steamid, function(err, res) {
console.log('Registered: ' + res); // <- this prints out my result
steamRegisterDate = res;
});
console.log(steamID); //<--- This returns undefined
res.render('steamid.hbs', {
"title": steamID,
"avatarURL": steamAvatarUrl,
"registerDate": steamRegisterDate
});
});
An help with an example/resolution of how I accomplish this would be amazing. I am a visual learner so please dont say "use this or do that" without giving some sort of example to it or I honestly wont get it lol.
Thanks ahead of time.