devnotes.

Async/Await Syntax

async/await (ES2017) is syntax sugar over promises that lets asynchronous code read top-to-bottom like synchronous code.

async function loadUser(id) {
  try {
    const res = await fetch(`/api/users/${id}`);
    const user = await res.json();
    return user;
  } catch (err) {
    console.error("Failed to load user:", err);
  }
}

An async function always returns a promise, even if you write a plain return inside it. await pauses execution of that function (without blocking the rest of the program) until the awaited promise settles, then either returns its resolved value or throws its rejection — which is exactly why a normal try/catch block can catch async errors instead of needing .catch().

To run independent async operations concurrently rather than one after another, use Promise.all([...]) and await the combined result, rather than await-ing each call in sequence — sequential awaits needlessly add up their individual durations.