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
- Fetch JSON
- Time out a request
- Handle errors in async code
- Run promises in parallel
- Wait for all promises, whatever happens
- Pause for a while
All promises and fetch commands · JavaScript 2025 cheatsheet