JavaScript

Async/await without the mystery

Understand promises and asynchronous JavaScript with a mental model you can apply immediately.

Priya Shah··5 min read·Updated Mar 3, 2025

async and await make promise-based code read from top to bottom. They do not make work synchronous—they give you a cleaner way to wait for a result.

Await a promise

An await expression pauses the current async function until its promise settles. Other JavaScript can still run while it waits.

async function loadProfile() {
  const response = await fetch('/api/profile');
  return response.json();
}

Handle failure deliberately

Use try and catch around work that can fail. Give people a useful next action rather than only logging an error.

Keep reading