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.