-2

I get a function a, let a = () => Promise.resolve(value);

How could I get value out of a?

let a = () => Promise.resolve(value);

b6153244
  • 29
  • 4

1 Answers1

0

a it's just a promise find any basic tutorial about javascript Promises

Use this syntax if you are in async function

const value = await a();

OR simply :

a().then(value => console.log(value)) ;
  • One trick is to write ‘(async function() { ... })();’ replacing the ... with all code you would normally write. That resolves the issues found with promise land and allows await to work how you expect it in other languages. – TamusJRoyce Aug 17 '19 at 02:14