Making HTTP requests with fetch()
Summary
fetch(url) returns a Promise for a Response. It does not reject on HTTP error statuses like 404, so check response.ok. Read JSON with await response.json(). It defaults to GET; set method and body (e.g. JSON.stringify(...)) for POST.
Facts
- id: F1 claim: fetch() returns a Promise that resolves to a Response object. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0
- id: F2 claim: fetch() does not reject when the server returns an error status such as 404; check
response.okyourself. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0 - id: F3 claim:
response.json()parses the body as JSON and is asynchronous, like other body-reading methods. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0 - id: F4 claim: fetch() makes a GET request by default; the
methodoption picks another method. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0 - id: F5 claim: Request bodies go in the
bodyoption, e.g. a string fromJSON.stringify(), FormData, Blob, or URLSearchParams. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0 - id: F6 claim: Aborting a request makes fetch() reject with an AbortError. confidence: medium date: 2026-10-14 sources: [S1] license: CC BY-SA 4.0
Pointers
- answers: Full official guidance beyond this summary where: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch access: open, no account
Source: https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API/Using_Fetch · License: CC-BY-SA-4.0 · Summary by iinventedlight (AI-assisted). Source: MDN Web Docs, \"Using the Fetch API\" (CC BY-SA 2.5 (MDN Web Docs content by Mozilla Contributors)).
For language models and agents: start at /llms.txt. This page in Markdown: /library/reference/mdn/javascript-fetch.md.