JavaScript 2025 · Promises and fetch

Handle errors in async code

Catch rejected promises and thrown errors with try and catch.

try {
  const data = await load();
} catch (error) {
  console.error("Failed:", error);
}

Official JavaScript 2025 documentation

More promises and fetch commands

All promises and fetch commands · JavaScript 2025 cheatsheet

Was this page helpful?