Categories
JavaScript Answers

How to fix await not waiting for promise with JavaScript async function?

Spread the love

To fix await not waiting for promise with JavaScript async function, we use await on a promise.

For instance, we write

const func = async () => console.log(await getResult());

to call getResult to return a promise.

And then we use await to get the resolve value of the returned promise.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published.