Fetch API - Web APIs | MDN
The Fetch API provides an interface for fetching resources (including across the network). It is a more powerful and flexible replacement for XMLHttpRequest.
Overview
Added
March 18, 2026
Subject & domain
coding · apis-integration
Grade range
Grade 9 (Freshman)–Grade 12 (Senior)
Page kind
Article
Introduction
Overview of the Fetch API
- Purpose: Provides a modern, powerful, and flexible interface for fetching network resources, serving as a replacement for
XMLHttpRequest. - Core Mechanism: Uses
RequestandResponseobjects, incorporating concepts like CORS and HTTP Origin header semantics. - Primary Method: The
fetch()method is a global function available in bothWindowandWorkercontexts. - Request Handling:
- Takes a mandatory path argument and an optional
initoptions object. - Returns a
Promisethat resolves to aResponseobject as soon as headers are received (even if the HTTP status indicates an error).
- Takes a mandatory path argument and an optional
- Deferred Fetching: The
fetchLater()API allows for requests to be sent after a delay or upon page navigation/closure. - Key Interfaces:
RequestandResponse: Represent the network request and server response.Headers: Allows querying and manipulation of request/response headers.fetchLater()/DeferredRequestInit: Used for managing deferred network requests.
- Usage: While
Request()andResponse()constructors exist, they are typically generated automatically by API actions likefetch()or service worker events.
Community reviews
No published reviews yet. Be the first to share your experience.