await
In one line
The await keyword pauses an async function until a promise settles, then resumes with the resolved value.
In simple words
await makes asynchronous code read like synchronous code. When you write const data = await fetch(url), the function pauses at that line until the promise from fetch settles, then resumes with the resolved value assigned to data.
await can only be used inside async functions (or at the top level in modern modules). If the awaited promise rejects, await throws the error, which you can catch with a regular try/catch block — no .catch() chaining needed.
While the function is paused at an await, the event loop is free to run other tasks. This is why await is non-blocking: your function waits, but the program does not. Other handlers, timers, and network responses keep running.
Example
async function loadUser() {
try {
const res = await fetch("/api/user");
const user = await res.json();
console.log(user);
} catch (err) {
console.error("Load failed:", err);
}
}await pauses until each promise settles. Errors are caught with a normal try/catch block.
Common confusions
Confused with: async
The difference:
awaitpauses execution inside an async function until a promise settles;asyncdeclares the function that allowsawait. You needasyncon the function to useawaitin its body.
Related terms
Related Resources
Related Lessons
- Async JavaScript
await in depth
Learn the fundamentals
Deepen your understanding with structured lessons on this topic.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.