Answer the question
In order to leave comments, you need to log in
How to return the result of a promise to a variable?
Good afternoon / evening, dear connoisseurs. I ran into a problem that I can’t solve, maybe someone will give good advice (if possible, describe the mechanism of work, please).
I have the following code:
var p1 = translate('Привет', {from: 'ru', to: lang}).then( function(res) {
return res.text
});
console.log(p1);
Promise { <pending> }
. How can I rewrite this code in such a way that I get the value returned to res.text
the variable p1
? Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question