Wednesday, 28 June 2017

javascript - Variables are not being set inside the .then() part of a Promise

return the value at function passed to .then()



var storedUserID = ROBLOX.getIdFromUsername(accountArg)
.then(function(userID) {
return userID;
});



you can then use or change the Promise value when necessary



storedUserID = storedUserID.then(id) {
return /* change value of Promise `storedUserID` here */
});


access and pass the value to message.reply() within .then()



storedUserID.then(function(id) {

message.reply(id);
});


or



var storedUserID = ROBLOX.getIdFromUsername(accountArg);
// later in code
storedUserID.then(function(id) {
message.reply(id);

});

No comments:

Post a Comment

casting - Why wasn't Tobey Maguire in The Amazing Spider-Man? - Movies & TV

In the Spider-Man franchise, Tobey Maguire is an outstanding performer as a Spider-Man and also reprised his role in the sequels Spider-Man...