Built-in fetch & Web Streams in Node.js

From the Node.js Core Modules cheat sheet · Modern Node.js (Built-in) · verified Jul 2026

Built-in fetch & Web Streams

fetch, Request, Response, Headers, FormData, AbortController — all global

javascript
// Built-in fetch (stable since Node 21) — no node-fetch needed
const res = await fetch('https://api.example.com/users')
if (!res.ok) throw new Error('HTTP ' + res.status)
const users = await res.json()

// Streaming a response
const res = await fetch('https://example.com/big.csv')
for await (const chunk of res.body) {
  process.stdout.write(chunk)
}

// Aborting a slow request
const ac = new AbortController()
const timer = setTimeout(() => ac.abort(), 5000)
try {
  const r = await fetch(url, { signal: ac.signal })
} finally {
  clearTimeout(timer)
}
💡 No more `node-fetch` — `fetch` is global in Node 18+ (stable in 21)
⚡ AbortSignal.timeout(ms) replaces the manual setTimeout dance
📌 Body is a Web ReadableStream — works with `for await` and pipeThrough
🎯 Backed by undici; drop down to undici directly for pooling control
fetchhttpstreamsmodern

Continue with Node.js Core Modules

Save the full cheat sheet or work through every related task.

More Node.js tasks

Back to the full Node.js Core Modules cheat sheet