Await is only valid in async function #184
-
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
|
There is two cases to use
For the first case, the specification is currently in progress and will come in the future For the second case, a function that call a
If you care about the result of the |
Beta Was this translation helpful? Give feedback.
-
|
This is more like a question. A top-level |
Beta Was this translation helpful? Give feedback.
awaitis syntax sugar aroundPromiseThere is two cases to use
await:For the first case, the specification is currently in progress and will come in the future
For the second case, a function that call a
Promisemust :callbackthat will be executed after thePromisefinished the asynchronous taskPromisedo side-effectPromiseIf you care about the result of the
Promiseand want to wait before executing others instructions, that means that this function will wait for an asynchronous task, and beasynchronous as well, that why theasynckeyword is required