Fetch API

Status: public · Confidence: medium (0.725) · Basis: verified_sources




## TL;DR

The Fetch API is a modern JavaScript interface for making HTTP requests, replacing XMLHttpRequest. Standardized by WHATWG, it uses Promises for asynchronous request handling and provides a cleaner, more powerful API for network operations.

## Core Explanation

Fetch provides the `fetch()` global function returning a Promise resolving to a Response object. Key features include: streaming responses via ReadableStream, CORS handling, request/response cloning, and AbortController integration for cancellation. Unlike XHR, fetch rejects only on network errors — HTTP error statuses (404, 500) still resolve successfully.

## Further Reading

- [Fetch Standard](https://fetch.spec.whatwg.org/)

## Related Articles

- [API Gateway](../api-gateway.md)
- [Broadcast Channel API](../broadcast-channel-api.md)
- [Canvas API](../canvas-api.md)