--- title: Fetch Response - Scoped,Global description: The Fetch Response API provides methods for creating a new Response object and for handling the response body created by a Fetch Request API method.Creates a new Response object using the Response\(\) constructor.Returns a promise that resolves with an ArrayBuffer.Returns a promise that resolves with a Blob.Returns a promise that resolves with an Uint8Array.Returns a promise that resolves with a FormData object.Returns a promise that resolves to the result of parsing the body text as JSON.Reads the response body and returns it as a plain string. The response is always decoded using UTF-8. locale: en-US canonical_url: https://www.servicenow.com/docs/r/australia/api-reference/server-api-reference/Fetch.ResponseAPI.html release: australia product: Server API Reference classification: server-api-reference topic_type: concept last_updated: "2026-03-12" reading_time_minutes: 12 breadcrumb: [Server API reference, API reference, API implementation and reference] --- # Fetch Response- Scoped,Global The Fetch Response API provides methods for creating a new Response object and for handling the response body created by a Fetch Request API method. The Fetch Response API is part of a set of Fetch APIs, which provide various actions for fetching resources from external websites. The full Fetch API collection includes: - [Fetch - fetch\(String resource, Object options\)](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/FetchAPI.md): Starts the process of fetching a resource from the network. - [Fetch Headers - Scoped, Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/Fetch.HeadersAPI.md): Retrieve and modify request and response headers. - [Fetch Request - Scoped, Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/Fetch.RequestAPI.md): Create a new request object. - [Fetch RequestInit - Scoped, Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/Fetch.RequestInitAPI.md): Set options to configure a fetch request. - [Fetch Response - Scoped,Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/Fetch.ResponseAPI.md): Create a new response object. To support fetch actions, the system property, `glide.hosts.allowlist`, allows controls over what hosts a fetch method can access. It applies to HTTP APIs like RestMessageV2 and those mentioned above. For more information about `glide.hosts.allowlist`, see [Available system properties](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/platform-administration/r_AvailableSystemProperties.md). ## Response properties The Response API provides properties that return details about the HTTP response. These properties allow you to access metadata \(like `status`, `headers`, `type`\) and the response body \(`body`\) for further processing. They enable checking the success of a request \(`ok`\) and parsing the returned data in various formats \(for example, JSON or text\). These properties are important for validating and handling server responses in client-side applications. To read more in-depth explanations about each property, see [https://developer.mozilla.org/en-US/docs/Web/API/Response](https://developer.mozilla.org/en-US/docs/Web/API/Response).
| Property name | Description | Example |
|---|---|---|
| body | Ready-only. Contains a readable stream of byte data in the response body contents.Valid values: A ReadableStream or null. Data type: String | ``` const request = new Request("/myEndpoint", { method: "POST", body: "Hello world", }); request.body; // ReadableStream ``` |
| bodyUsed | Ready-only. Flag that indicates whether the body has been read yet.Accepted values: - true: Body has been read. - false: Body hasn't been read. Data type: Boolean | ``` const request = new Request("/myEndpoint", { method: "POST", body: "Hello world", }); request.bodyUsed; // false request.text().then((bodyAsText) => { console.log(request.bodyUsed); // true }); ``` |
| headers | Read-only. The Headers object associated with the response.Data type: Headers object | ``` const myRequest = new Request("flowers.jpg"); const myHeaders = myRequest.headers; // Headers {} ``` |
| ok | Ready-only. Flag indicating whether the response was successful \(status in the range 200-299\) or not.Accepted values: - true: The response was successful. - false: The response wasn't successful. Data type: Boolean | ``` const myImage = document.querySelector("img"); const myRequest = new Request("flowers.jpg"); fetch(myRequest).then((response) => { console.log(response.ok); // returns true if the response returned successfully response.blob().then((myBlob) => { const objectURL = URL.createObjectURL(myBlob); myImage.src = objectURL; }); }); ``` |
| redirected | Read-only. Flag indicating whether the response is a result that the request was redirected.Accepted values: - true: request was redirected. - false: request wasn't redirected. Data type: Boolean | ``` const myRequest = new Request("flowers.jpg"); const myCred = myRequest.redirect; ``` |
| status | Read-only. HTTP status codes of the response. For example, 200 for a success.Data type: Number | ``` const myImage = document.querySelector("img"); const myRequest = new Request("flowers.jpg"); fetch(myRequest) .then((response) => { console.log("response.status =", response.status); // response.status = 200 return response.blob(); }) .then((myBlob) => { const objectURL = URL.createObjectURL(myBlob); myImage.src = objectURL; }); ``` |
| statusText | Read-only. Status message corresponding to the HTTP status code in response.status. For example, this would be `OK` for a status code `200`, `Continue` for `100`, `Not Found` for `404`.Data type: String | ``` const myRequest = new Request("flowers.jpg"); // Log the HTTP status and status text console.log(`Status: ${response.status}`); console.log(`Status Text: ${response.statusText}`); // Check if the response is successful if (response.ok) { console.log("Request succeeded!"); } else { console.log("Request failed."); } } catch (error) { console.error("Error fetching the URL:", error); } } ``` |
| type | Read-only. Type of response.Accepted values: - basic: Normal, same origin response, with all headers exposed except "Set-Cookie". - cors: Response was received from a valid cross-origin request. Certain headers and the body may be accessed. - error: Network error. No useful information describing the error is available. The Response's status is 0, headers are empty and immutable. This is the type for a Response obtained from `Response.error()`. - opaque: Response for "no-cors" request to cross-origin resource. Severely restricted. - opaqueredirect: The fetch request was made with `redirect: "manual"`. The Response's status is 0, headers are empty, body is null and trailer is empty. Data type: String | ``` const myImage = document.querySelector("img"); const myRequest = new Request("flowers.jpg"); fetch(myRequest) .then((response) => { console.log("response.type =", response.type); // response.type = 'basic' return response.blob(); }) .then((myBlob) => { const objectURL = URL.createObjectURL(myBlob); myImage.src = objectURL; }); ``` |
| url | Read-only. URL of the response.Data type: String | ``` const myRequest = new Request("flowers.jpg"); const myURL = myRequest.url; // "https://github.com/mdn/dom-examples/tree/main/fetch/fetch-request/flowers.jpg" ``` |
| Name | Type | Description |
|---|---|---|
| body | Object | Optional. An object defining a body for the response.Valid types: - ArrayBuffer - Blob - DataView - FormData - ReadableStream - String - String literal - TypedArray - URLSearchParams Default: null |
| options | Object | Optional. An options object containing any custom settings that you want to apply to the response, or an empty object \(which is the default value\). The possible options are:- headers: Any headers you want to add to your response, contained within a [Fetch Headers - Scoped, Global](https://raw.githubusercontent.com/ServiceNow/ServiceNowDocs/australia/markdown/australia/api-reference/server-api-reference/Fetch.HeadersAPI.md) object or object literal of string key/value pairs \(see [HTTP headers](https://developer.mozilla.org/en-US/docs/Web/HTTP/Headers) for a reference\). Empty by default. - status: The status code for the response. The default value is `200`. - statusText: The status message associated with the status code, such as `"OK"`. The default value is `""`. |
| Exception | Description |
|---|---|
| DOMException - AbortError | An exception stating that the request was aborted. |
| TypeError | Thrown for one of the following reasons: - The response body is disturbed or locked. - There was an error decoding the body content \(for example, because the Content-Encoding header is incorrect\). |
| RangeError | There was a problem creating the associated `ArrayBuffer`. For example, if the data size is too large. |
| Exception | Description |
|---|---|
| DOMException - AbortError | An exception stating that the request was aborted. |
| TypeError | Thrown for one of the following reasons: - The response body is disturbed or locked. - There was an error decoding the body content \(for example, because the Content-Encoding header is incorrect\). |
| Exception | Description |
|---|---|
| DOMException- AbortError | The request was aborted. |
| TypeError | Thrown for one of the following reasons: - The response body is disturbed or locked. - There was an error decoding the body content \(for example, because the Content-Encoding header is incorrect\). |
| RangeError | There was a problem creating the associated `ArrayBuffer`. For example, if the data size is too large. |
| Exception | Description |
|---|---|
| DOMException- AbortError | The request was aborted. |
| TypeError | Thrown for one of the following reasons: - The response body is disturbed or locked. - There was an error decoding the body content \(for example, because the Content-Encoding header is incorrect\). |
| Exception | Description |
|---|---|
| DOMException- AbortError | The request was aborted. |
| TypeError | Thrown for one of the following reasons: - The response body is disturbed or locked. - There was an error decoding the body content \(for example, because the Content-Encoding header is incorrect\). |
| SyntaxError | The response body cannot be parsed as JSON. |
| Exception | Description |
|---|---|
| DOMException- AbortError | The request was aborted. |
| TypeError | Thrown for one of the following reasons: - The response body is disturbed or locked. - There was an error decoding the body content \(for example, because the Content-Encoding header is incorrect\). |