-
Notifications
You must be signed in to change notification settings - Fork 0
Async Await
Kyle Coberly edited this page Jun 10, 2018
·
1 revision
- Putting
asyncin front of a function declaration make it anAsyncFunctionobject and is treated like a promise -
awaitcan only be used inside ofAsyncFunctions- Ergo, can't be used at the top level
-
awaitpauses the execution of the function until the promise that you pass it resolves, kind of like a generator
async function somethingThatUsesAwait(){
const result = await networkRequest();
return result;
}
somethingThatUsesAwait().then(result => {
// Using promises now
});