JavaScript 2025 · Promises and fetch

POST JSON

Send a JSON body with the right header.

const res = await fetch("/api/users", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify({ name: "Ada" }),
});

Official JavaScript 2025 documentation

More promises and fetch commands

All promises and fetch commands · JavaScript 2025 cheatsheet

Was this page helpful?