await
noun
say it: “uh-WAYT” /əˈweɪt/
The JavaScript keyword that pauses an async function until a promise finishes, then gives its result.
What does await do in JavaScript?
await — An operator that pauses an async function until a value or Promise settles.
async function loadOrder() {
const response = await fetch("/api/order");
return response.json();
}
In a sentence
- “const response = await fetch(url); waits for the server to answer.”
Level: Journeyman · More JavaScript terms at this level
Updated