Async Await Promises
async keyword before the
function name, or before
() when using the async arrow function. An
async function always returns a promise.
async function can contain statements preceded by an
await operator. The operand of
await is a promise. At an
await expression, the execution of the
async function is paused and waits for the operand promise to resolve. The
await operator returns the promise’s resolved value. An
await operand can only be used inside an
Async Function Error Handling
async functions uses
try...catch statements for error handling. This method allows shared error handling for synchronous and asynchronous code.
async...await, multiple asynchronous operations can run concurrently. If the resolved value is required for each promise initiated,
Promise.all() can be used to retrieve the resolved value, avoiding unnecessary blocking.