I'm using node.js, and since this is my first time working with both javascript and asynchronous programming, things are going pretty rough. So I have this piece of code that outputs the result of a resolved promise:
promise.then(function(result) {
console.log(result)
});
// outputs result
It works as intended, but I don't need the result in the console, I need to pass it into some variable so that it can be used later. Like this:
promise.then(function(result) {
//magic
});
//maybe some more magic
console.log(myvar)
// outputs result
Is there any way to do this? Thank you in advance. Please pardon my grammar, English isn't my native tongue.