async/await

async/await is syntax that makes asynchronous code look like synchronous code. An async function always returns a promise, and await suspends its execution until a promise settles, without blocking the rest of the program. It is used inside an async function or at the top level of a module.

Example

async function charger() {
  const r = await fetch('/api/items')
  return r.json()
}

Related concepts

The whole glossary