JavaScript Fetch API

The Fetch API provides a JavaScript interface for accessing and manipulating parts of the protocol, such as requests and responses.

Definition and Usage

The fetch() method starts the process of fetching a resource from a server.

The fetch() method returns a Promise that resolves to a Response object.

No need for XMLHttpRequest anymore.

Syntax

fetch(file)

Parameters

Parameter Description
file Optional.
The name of a resource to fetch.

Return Value

Type Description
PromiseA Promise that resolves to a Response object.

Browser Support

fetch() is an ECMAScript6 (ES6) feature.

ES6 (JavaScript 2015) is supported in all modern browsers:

fetch() is not supported in Internet Explorer 11 (or earlier).