Async functions, async / await
suggest changeIntroduction
async and await build on top of promises and generators to express asynchronous actions inline. This makes asynchronous or callback code much easier to maintain.
Functions with the async keyword return a Promise, and can be called with that syntax.
Inside an async function, await applies to a promise and resumes the function after that promise settles. A fulfillment becomes the value of the await expression. A rejection throws, so a surrounding try/catch can handle it.
Remarks
Async functions are syntactic sugar over promises. They are more readable, keep error handling in try/catch, and need fewer levels of indentation.
Async functions compared to Promises
Simultaneous async parallel operations
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents