← Reference notes

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

Pointers

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.