en.javascript.info/1-js/11-async/07-async-await/03-async-from-regular/solution.md
Ilya Kantor 3113f7deef up
2019-03-07 15:14:56 +03:00

339 B

That's the case when knowing how it works inside is helpful.

Just treat async call as promise and attach .then to it:

async function wait() {
  await new Promise(resolve => setTimeout(resolve, 1000));

  return 10;
}

function f() {
  // shows 10 after 1 second
*!*
  wait().then(result => alert(result));
*/!*
}

f();