What does async/await do?
By FrontendPro Editorial Team Updated 9/26/2026
Answer
It lets you write promise-based code in a straight line. async makes a function return a promise; await pauses that function until a promise settles, giving you the value or throwing the reason.
// promise chain
function load(id) {
return fetchUser(id)
.then((user) => fetchPosts(user.id))
.then((posts) => posts.filter((p) => p.published))
.catch(handleError);
}
// same thing
async function load(id) {
try {
const user = await fetchUser(id);
const posts = await fetchPosts(user.id);
return posts.filter((p) => p.published);
} catch (err) {
handleError(err);
}
}
What it actually improves
Intermediate values stay in scope — in a chain, user is not visible in the second .then, so people resort to nesting or passing tuples along. And ordinary try...catch, if and loops work again, which they do not inside a chain.
It does not block the thread
await suspends only that function. The event loop carries on, so other code, rendering and events proceed normally.
The mistake to avoid: accidental sequencing
const a = await loadA(); // 1s
const b = await loadB(); // another 1s — 2s total, for no reason
If they do not depend on each other, start both first:
const [a, b] = await Promise.all([loadA(), loadB()]); // 1s
The same applies to loops: for...of with await is sequential, which is right when order matters and wasteful when it does not.
Three details
An async function always returns a promise, even when you return a plain value. Calling one without await starts the work but does not wait — and if it rejects, you get an unhandled rejection. And await at the top level works only in ES modules.
