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 Request and Response objects, incorporating concepts like CORS and HTTP Origin header semantics.
  • Primary Method: The fetch() method is a global function available in both Window and Worker contexts.
  • Request Handling:
    • Takes a mandatory path argument and an optional init options object.
    • Returns a Promise that resolves to a Response object as soon as headers are received (even if the HTTP status indicates an error).
  • Deferred Fetching: The fetchLater() API allows for requests to be sent after a delay or upon page navigation/closure.
  • Key Interfaces:
    • Request and Response: 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() and Response() constructors exist, they are typically generated automatically by API actions like fetch() or service worker events.

Community reviews

No published reviews yet. Be the first to share your experience.