This feature is well established and works across many devices and browser versions. It’s been available across browsers since March 2017.
* Some parts of this feature may have varying levels of support.
Note: This feature is available in Web Workers.
The Request interface of the Fetch API represents a resource request.
You can create a new Request object using the Request() constructor, but you are more likely to encounter a Request object being returned as the result of another API operation, such as a service worker FetchEvent.request.
Request()Creates a new Request object.
Request.body Read only
A ReadableStream of the body contents.
Request.bodyUsed Read only
Stores true or false to indicate whether or not the body has been used in a request yet.
Request.cache Read only
Contains the cache mode of the request (e.g., default, reload, no-cache).
Request.credentials Read only
Contains a value controlling whether credentials should be included with the request (e.g., omit, same-origin, include). The default is same-origin.
Request.destination Read only
A string describing the type of content being requested.
Request.headers Read only
Contains the associated Headers object of the request.
Request.integrity Read only
Contains the subresource integrity value of the request (e.g., sha256-BpfBw7ivV8q2jLiT13fxDYAe2tJllusRSZ273h2nFSE=).
A boolean indicating whether the request is a history navigation.
Request.keepalive Read only
Contains the request's keepalive setting (true or false), which indicates whether the browser will keep the associated request alive if the page that initiated it is unloaded before the request is complete.
Request.method Read only
Contains the request's method (GET, POST, etc.)
Request.mode Read only
Contains the mode of the request (e.g., cors, no-cors, same-origin, navigate.)
Request.redirect Read only
Contains the mode for how redirects are handled. It may be one of follow, error, or manual.
Request.referrer Read only
Contains the referrer of the request (e.g., client).
Request.referrerPolicy Read only
Contains the referrer policy of the request (e.g., no-referrer).
Request.signal Read only
Returns the AbortSignal associated with the request
Request.url Read only
Contains the URL of the request.
Request.arrayBuffer()Returns a promise that resolves with an ArrayBuffer representation of the request body.
Request.blob()Returns a promise that resolves with a Blob representation of the request body.
Request.bytes()Returns a promise that resolves with a Uint8Array representation of the request body.
Request.clone()Creates a copy of the current Request object.
Request.formData()Returns a promise that resolves with a FormData representation of the request body.
Request.json()Returns a promise that resolves with the result of parsing the request body as JSON.
Request.text()Returns a promise that resolves with a text representation of the request body.
Note: The request body functions can be run only once; subsequent calls will reject with TypeError showing that the body stream has already used.
In the following snippet, we create a new request using the Request() constructor (for an image file in the same directory as the script), then return some property values of the request:
const request = new Request("https://www.mozilla.org/favicon.ico");
const url = request.url;
const method = request.method;
const credentials = request.credentials;
You could then fetch this request by passing the Request object in as a parameter to a fetch() call, for example:
fetch(request)
.then((response) => response.blob())
.then((blob) => {
image.src = URL.createObjectURL(blob);
});
In the following snippet, we create a new request using the Request() constructor with some initial data and body content for an API request which needs a body payload:
const request = new Request("https://example.com", {
method: "POST",
body: '{"foo": "bar"}',
});
const url = request.url;
const method = request.method;
const credentials = request.credentials;
const bodyUsed = request.bodyUsed;
Note: The body can only be a Blob, an ArrayBuffer, a TypedArray, a DataView, a FormData, a URLSearchParams, a ReadableStream, or a String object, as well as a string literal, so for adding a JSON object to the payload you need to stringify that object.
You could then fetch this API request by passing the Request object in as a parameter to a fetch() call, for example and get the response:
fetch(request)
.then((response) => {
if (response.status !== 200) {
throw new Error("Something went wrong on API server!");
}
return response.json();
})
.then((response) => {
console.debug(response);
// …
})
.catch((error) => {
console.error(error);
});
| Specification |
|---|
| Fetch> # request-class> |
| Desktop | Mobile | |||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
| Chrome | Edge | Firefox | Opera | Safari | Chrome Android | Firefox for Android | Opera Android | Safari on IOS | Samsung Internet | WebView Android | WebView on iOS | |
Request |
40From Chrome 47, default values for theinit argument's properties changed. mode defaults to same-origin (from no-cors). credentials defaults to include (from same-origin). redirect defaults to follow (from manual). |
14 | 39 | 27 | 10.1 | 40From Chrome Android 47, default values for theinit argument's properties changed. mode defaults to same-origin (from no-cors). credentials defaults to include (from same-origin). redirect defaults to follow (from manual). |
39 | 27 | 10.3 | 4.0From Samsung Internet 5.0, default values for theinit argument's properties changed. mode defaults to same-origin (from no-cors). credentials defaults to include (from same-origin). redirect defaults to follow (from manual). |
40From WebView Android 47, default values for theinit argument's properties changed. mode defaults to same-origin (from no-cors). credentials defaults to include (from same-origin). redirect defaults to follow (from manual). |
10.3 |
Request |
4240–42Only available in service workers. |
14 | 39 | 2927–29Only available in service workers. |
10.1 | 4240–42Only available in service workers. |
39 | 2927–29Only available in service workers. |
10.3 | 4.0 | 4240–42Only available in service workers. |
10.3 |
arrayBuffer |
42 | 14 | 39 | 29 | 10.1 | 42 | 39 | 29 | 10.3 | 4.0 | 42 | 10.3 |
blob |
42 | 14 | 39 | 29 | 10.1 | 42 | 39 | 29 | 10.3 | 4.0 | 42 | 10.3 |
body |
105 | 105 | No | 91 | 11.1 | 105 | No | 72 | 11.3 | 20.0 | 105 | 11.3 |
bodyUsed |
42 | 14 | 39 | 29 | 10.1 | 42 | 39 | 29 | 10.3 | 4.0 | 42 | 10.3 |
bytes |
132 | 132 | 128 | 117 | 18 | 132 | 128 | 87 | 18 | No | 132 | 18 |
cache |
64 | 14 | 48 | 51 | 10.1 | 64 | 48 | 47 | 10.3 | 9.0 | 64 | 10.3 |
clone |
40 | 14 | 39 | 27 | 10.1 | 40 | 39 | 27 | 10.3 | 4.0 | 40 | 10.3 |
credentials |
40 | 14 | 39 | 27 | 10.1 | 40 | 39 | 27 | 10.3 | 4.0 | 40 | 10.3 |
destination |
65 | 14 | 61 | 52 | 10.1 | 65 | 61 | 47 | 10.3 | 9.0 | 65 | 10.3 |
duplex |
131 | 131 | No | 116 | No | No | No | No | No | No | No | No |
formData |
60 | 79 | 39 | 47 | 14.1 | 60 | 39 | 44 | 14.5 | 8.0 | 60 | 14.5 |
headers |
40 | 14 | 39 | 27 | 10.1 | 40 | 39 | 27 | 10.3 | 4.0 | 40 | 10.3 |
integrity |
46 | 14 | 51 | 33 | 10.1 | 46 | 51 | 33 | 10.3 | 5.0 | 46 | 10.3 |
isHistoryNavigation |
69 | 79 | No | 56 | No | 69 | No | 48 | No | 10.0 | 69 | No |
json |
42 | 14 | 39 | 29 | 10.1 | 42 | 39 | 29 | 10.3 | 4.0 | 42 | 10.3 |
keepalive |
66 | 15 | 133 | 53 | 13 | 66 | 133 | 47 | 13 | 9.0 | 66 | 13 |
method |
40 | 14 | 39 | 27 | 10.1 | 40 | 39 | 27 | 10.3 | 4.0 | 40 | 10.3 |
mode |
40 | 14 | 39 | 27 | 10.1 | 40 | 39 | 27 | 10.3 | 4.0 | 40 | 10.3 |
redirect |
46 | 14 | 43 | 33 | 10.1 | 46 | 43 | 33 | 10.3 | 5.0 | 46 | 10.3 |
referrer |
40 | 14 | 39 | 27 | 10.1 | 40 | 39 | 27 | 10.3 | 4.0 | 40 | 10.3 |
referrerPolicy |
52 | 14 | 47 | 39 | 10.1 | 52 | 47 | 41 | 10.3 | 7.2 | 52 | 10.3 |
signal |
66 | 16 | 57 | 53 | 12.1 | 66 | 57 | 47 | 12.2 | 9.0 | 66 | 12.2 |
targetAddressSpace |
138124–138 | 138124–138 | No | 122110–122 | No | 138124–138 | No | 82–91 | No | 27.0 | 124–138 | No |
text |
42 | 14 | 39 | 29 | 10.1 | 42 | 39 | 29 | 10.3 | 4.0 | 42 | 10.3 |
url |
40Fragment support added in Chrome 59. |
14 | 39 | 27Fragment support added in Opera 46. |
10.1 | 40Fragment support added in Chrome Android 59. |
39 | 27Fragment support added in Opera 46. |
10.3 | 4.0Fragment support added in Samsung Internet 7.0. |
40Fragment support added in WebView Android 59. |
10.3 |
© 2005–2025 MDN contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/Request