Fetch API
Updated 2026-02-15
fetch() for HTTP requests: GET, POST, headers, and streaming. Request and Response APIs.
GET and parsing
fetch(url) returns Promise<Response>. await res.json(), res.text(), res.blob(). res.ok (2xx), res.status. Headers: res.headers.get('name').
POST and options
fetch(url, { method: 'POST', headers: { 'Content-Type': 'application/json' }, body: JSON.stringify(data) }). FormData: body: formData, no Content-Type.
Request and streaming
new Request(url, options). new Response(body, { status, headers }). res.body ReadableStream for streaming. AbortController with signal for cancel.