JavaScript await Keyword Explained

JavaScript Logo

await Keyword – `await` pauses async function execution until the promise resolves, then returns its result.

๐Ÿ‘‰ Syntax

const result = await promise;

๐Ÿงช Example

async function main() {
  const user = await fetch('/user').then(r => r.json());
  console.log(user);
}

Comments