---
sourceDocument: Australia API Reference
sourceDocumentLink: https://servicenow-prod.fluidtopics.net/r/de-DE/api-reference

 Release :

    - australia

ft:locale :

    - de-DE

ft:publication_title :

    - Australia API Reference

ft:clusterId :

    - crapiref

bundleId :

    - crapiref

workflow :

    - Creator


---

# Fetch Response - Scoped,Global

# Fetch Response - Scoped,Global {#ariaid-title1}

* Freigeben Version: Australia
* 
* Aktualisiert 12. März 2026
* 
* ![](https://www.servicenow.com/docs/portal-asset/ico-clock) 11 Minuten Lesedauer

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://servicenow-prod.fluidtopics.net/sNaWbU1GyFu9dZ9JJVfu_w#fetch.fetch_S_O "Starts the process of fetching a resource from the network and returns a promise that is fulfilled once the response is available."): Starts the process of fetching a resource from the network.
* [Fetch Headers - Scoped, Global](https://servicenow-prod.fluidtopics.net/WltVVCBjXG8ySmUtptd0Uw#Fetch.HeadersAPI "The Fetch Headers API allows you to retrieve, set, add to, and remove headers from a list of request or response headers."): Retrieve and modify request and response headers.
* [Fetch Request - Scoped, Global](https://servicenow-prod.fluidtopics.net/xVHs1z3GeKYU_rfACd7MHQ#Fetch.RequestAPI "The Fetch Request API contains methods for creating or retrieving a Request object to allow applications to asynchronously request resources, such as JSON, text, or binary data, from a server, and handle the response. This API supports various HTTP methods like GET, POST, PUT, DELETE, and so on."): Create a new request object.
* [Fetch RequestInit - Scoped, Global](https://servicenow-prod.fluidtopics.net/rq3f~xAVzfs3fSr8a6t5Rw#Fetch.RequestInitAPI "The RequestInit API provides options to configure a Fetch request."): Set options to configure a fetch request.
* [Fetch Response - Scoped,Global](https://servicenow-prod.fluidtopics.net/AinAHOMu3K0yEa367bTUug#Fetch.ResponseAPI "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."): Create a new response object.
{#Fetch.ResponseAPI__ul_akb_fsf_pdc}

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://www.servicenow.com/docs/access?context=r_AvailableSystemProperties&version=australia&pubname=australia-platform-administration&ft:locale=en-US).

## Response properties {#Fetch.ResponseAPI__section_ftr_brq_12c}

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>.
{#Fetch.ResponseAPI__table_t5x_2qw_jdc__entry__3}

| 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. {#Fetch.ResponseAPI__ul_sd1_f4x_jdc} 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. {#Fetch.ResponseAPI__ul_lqz_y4r_c2c} 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" |
[Tabelle : 1. Response properties]

{#Fetch.ResponseAPI__table_t5x_2qw_jdc}

## Fetch Response - Response(Object body, Object options) {#ariaid-title2}

Creates a new Response object using the Response() constructor.
{#fetch.response-constructor__table_bt1_vly_12c__entry__3}

| 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 {#fetch.response-constructor__ul_vxx_gmy_12c} 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://servicenow-prod.fluidtopics.net/WltVVCBjXG8ySmUtptd0Uw#Fetch.HeadersAPI "The Fetch Headers API allows you to retrieve, set, add to, and remove headers from a list of request or response headers.") 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 `""`. {#fetch.response-constructor__ul_nz3_qmy_12c} |
[Tabelle : 2. Parameters]

{#fetch.response-constructor__table_bt1_vly_12c}  
In this example, we create a new Response object using the constructor, passing a new Blob as a body, and an init object containing custom status and statusText options:

    const myBlob = new Blob();
    const myOptions = { status: 200, statusText: "Status message!" };
    const myResponse = new Response(myBlob, myOptions);

## Fetch Response - arrayBuffer() {#ariaid-title3}

Returns a promise that resolves with an ArrayBuffer.
The arrayBuffer() method is useful when working with binary data like images, audio files, or any other binary file that needs to be processed.
{#fetch.response-arrayBuffer__table_ohy_l2s_kdc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 3. Parameters]

{#fetch.response-arrayBuffer__table_ohy_l2s_kdc} {#fetch.response-arrayBuffer__table_phy_l2s_kdc__entry__2}

| Type | Description |
|-|-|
| Object | A promise that resolves with an [ArrayBuffer](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer), which represents a generic raw binary data buffer. |
[Tabelle : 4. Returns]

{#fetch.response-arrayBuffer__table_phy_l2s_kdc} {#fetch.response-arrayBuffer__table_szf_1gs_kdc__entry__2}

| 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). {#fetch.response-arrayBuffer__ul_qpv_ggs_kdc} |
| RangeError | There was a problem creating the associated `ArrayBuffer`. For example, if the data size is too large. |
[Tabelle : 5. Exceptions]

{#fetch.response-arrayBuffer__table_szf_1gs_kdc}  
The following example script fetches binary data from a server and processes it while utilizing the arrayBuffer() method using these steps:

1. fetch(): Fetches a resource from the specified URL.
2. response.ok: Checks if the response status is in the 200-299 range.
3. arrayBuffer(): Reads the response body and converts it into an ArrayBuffer, which represents a generic, fixed-length raw binary data buffer.
4. Uint8Array: Converts the ArrayBuffer into a Uint8Array, which is a typed array for easy manipulation of binary data.

    javascriptCopy code// Simple API to fetch binary data and process it using arrayBuffer()asyncfunctionfetchBinaryData(url) {
      try {
        // Fetch the resource from the provided URLconst response = awaitfetch(url);

        // Check if the response is successfulif (!response.ok) {
          thrownewError(`HTTP error! Status: ${response.status}`);
        }

        // Convert the response body to an ArrayBufferconst arrayBuffer = await response.arrayBuffer();

        // Process the ArrayBuffer (e.g., convert it to a typed array)const uint8Array = newUint8Array(arrayBuffer);

        // Return the processed datareturn uint8Array;
      } catch (error) {
        console.error("Error fetching or processing binary data:", error);
        throw error;
      }
    }

    // Example usageconst binaryDataUrl = 'https://example.com/path/to/binary/data';

    fetchBinaryData(binaryDataUrl)
      .then((data) => {
        console.log("Binary data as Uint8Array:", data);
        // Further processing can be done here, e.g., rendering an image or playing audio
      })
      .catch((error) => {
        console.error("Failed to fetch binary data:", error);
      });

## Fetch Response - blob() {#ariaid-title4}

Returns a promise that resolves with a Blob.
{#fetch.response-blob__table_ygl_5gs_kdc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 6. Parameters]

{#fetch.response-blob__table_ygl_5gs_kdc} {#fetch.response-blob__table_zgl_5gs_kdc__entry__2}

| Type | Description |
|-|-|
| Object | A promise that resolves with a [Blob](https://developer.mozilla.org/en-US/docs/Web/API/Blob). |
[Tabelle : 7. Returns]

{#fetch.response-blob__table_zgl_5gs_kdc} {#fetch.response-blob__table_szf_1gs_kdc__entry__2}

| 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). {#fetch.response-blob__ul_qpv_ggs_kdc} |
[Tabelle : 8. Exceptions]

{#fetch.response-blob__table_szf_1gs_kdc}  
The following example demonstrates how to use the blob() method with the Fetch API using the following steps. This use case is great for fetching images or other binary content (like videos or PDFs) and displaying them dynamically.

1. fetch(url): Fetches a resource from the specified URL.
2. response.blob(): Converts the response body into a Blob object, which represents binary data.
3. URL.createObjectURL(blob): Generates a temporary URL for the Blob, which can be used in the DOM (for example, as an image source).
4. Appending the image to the DOM: Dynamically creates an image element, sets the blob URL as its source, and appends it to the document body.
{#fetch.response-blob__ol_k5n_zpy_12c}


    async function fetchBlob(url) {
      try {
        // Fetch the resource from the provided URL
        const response = await fetch(url);

        // Check if the response is successful
        if (!response.ok) {
          throw new Error(`HTTP error! Status: ${response.status}`);
        }

        // Convert the response body to a Blob
        const blob = await response.blob();

        // Create a URL for the Blob and log it
        const blobUrl = URL.createObjectURL(blob);
        console.log("Blob URL:", blobUrl);

        // For example, you can set it as the source of an image
        const img = document.createElement('img');
        img.src = blobUrl;
        img.alt = "Fetched Blob Image";
        document.body.appendChild(img);
      } catch (error) {
        console.error("Error fetching or processing blob:", error);
      }
    }

    // Example usage with an image URL
    const imageUrl = 'https://via.placeholder.com/150';
    fetchBlob(imageUrl);

## Fetch Response - bytes() {#ariaid-title5}

Returns a promise that resolves with an Uint8Array.
{#fetch.response-bytes__table_hrj_nhs_kdc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 9. Parameters]

{#fetch.response-bytes__table_hrj_nhs_kdc} {#fetch.response-bytes__table_irj_nhs_kdc__entry__2}

| Type | Description |
|-|-|
| Object | A promise that resolves with an Uint8Array. |
[Tabelle : 10. Returns]

{#fetch.response-bytes__table_irj_nhs_kdc} {#fetch.response-bytes__table_szf_1gs_kdc__entry__2}

| 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). {#fetch.response-bytes__ul_qpv_ggs_kdc} |
| RangeError | There was a problem creating the associated `ArrayBuffer`. For example, if the data size is too large. |
[Tabelle : 11. Exceptions]

{#fetch.response-bytes__table_szf_1gs_kdc}  
The following example shows how to fetch a text file, return the body as a Uint8Array, and then decode this into a string.

    const response = await fetch("https://www.example.com/textfile.txt");
    const textFile = await response.bytes();
    const string = new TextDecoder().decode(textFile);
    console.log(string);

## Fetch Response - formData() {#ariaid-title6}

Returns a promise that resolves with a FormData object.
{#fetch.response-formData__table_n2q_ldt_kdc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 12. Parameters]

{#fetch.response-formData__table_n2q_ldt_kdc} {#fetch.response-formData__table_o2q_ldt_kdc__entry__2}

| Type | Description |
|-|-|
| Object | A promise that resolves with a [FormData](https://developer.mozilla.org/en-US/docs/Web/API/FormData) object. |
[Tabelle : 13. Returns]

{#fetch.response-formData__table_o2q_ldt_kdc} {#fetch.response-formData__table_szf_1gs_kdc__entry__2}

| 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). {#fetch.response-formData__ul_qpv_ggs_kdc} |
[Tabelle : 14. Exceptions]

{#fetch.response-formData__table_szf_1gs_kdc}  
The following example demonstrates how to use formData() to process a form submission response using the following steps:

1. Request Body: Used `JSON.stringify()` to send the form data as JSON instead of URL-encoded parameters.
2. Content-Type: Set to `application/json` to indicate the request body format.
{#fetch.response-formData__ol_qvl_qry_12c}

    // Example of using Response.formData()
    async function fetchFormData(url) {
      try {
        // Make a POST request to fetch the form data
        const response = await fetch(url, {
          method: 'POST',
          body: JSON.stringify({
            name: 'John Doe',
            email: 'john.doe@example.com',
          }),
          headers: {
            'Content-Type': 'application/json',
          },
        });

        // Check if the response is successful
        if (!response.ok) {
          throw new Error(`HTTP error! Status: ${response.status}`);
        }

        // Parse the response as FormData
        const formData = await response.formData();

        // Iterate through the FormData entries
        for (const [key, value] of formData.entries()) {
          console.log(`${key}: ${value}`);
        }
      } catch (error) {
        console.error("Error fetching or processing form data:", error);
      }
    }

    // Example usage
    const formEndpoint = 'https://httpbin.org/post'; // Replace with your form endpoint
    fetchFormData(formEndpoint);

Output:

    name: John Doe
    email: john.doe@example.com

## Fetch Response - json() {#ariaid-title7}

Returns a promise that resolves to the result of parsing the body text as JSON.
Hinweis:  
Despite the name of this method, the result of json() is not JSON but is instead the result of taking JSON as input and parsing it to produce a JavaScript object.
{#fetch.response-json__table_agq_tdt_kdc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 15. Parameters]

{#fetch.response-json__table_agq_tdt_kdc} {#fetch.response-json__table_bgq_tdt_kdc__entry__2}

| Type | Description |
|-|-|
| Object | A promise that resolves to a JavaScript object. This object could be anything that can be represented by JSON, like an object, array, string, number, and so on. |
[Tabelle : 16. Returns]

{#fetch.response-json__table_bgq_tdt_kdc} {#fetch.response-json__table_szf_1gs_kdc__entry__2}

| 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). {#fetch.response-json__ul_qpv_ggs_kdc} |
| SyntaxError | The response body cannot be parsed as JSON. |
[Tabelle : 17. Exceptions]

{#fetch.response-json__table_szf_1gs_kdc}  
The following example demonstrates how to use json() to form a response:

1. fetch() makes a GET request to the URL.
2. The response.ok checks if the request was successful (status code 200--299).
3. If successful, response.json() is called to parse the JSON data from the response.
4. The parsed data is logged to system logs using the Console API. If any error occurs during the request or parsing, it's caught and logged.
{#fetch.response-json__ol_wjm_dqr_c2c}

    fetch('https://jsonplaceholder.typicode.com/posts/1')
      .then(response => {
        if (!response.ok) {
          throw new Error('Network response was not ok');
        }
        return response.json();
      })
      .then(data => console.log(data))
      .catch(error => console.error('Fetch error:', error));

## Fetch Response - text() {#ariaid-title8}

Reads the response body and returns it as a plain string. The response is always decoded using UTF-8.
The text() method is useful for responses that contain textual data, such as HTML, JSON (if you want to handle it manually), XML, or plain text files that are meant to be treated as plain strings.
{#fetch.response-text__table_hjn_l2t_kdc__entry__3}

| Name | Type | Description |
|-|-|-|
| None |   |   |
[Tabelle : 18. Parameters]

{#fetch.response-text__table_hjn_l2t_kdc} {#fetch.response-text__table_ijn_l2t_kdc__entry__2}

| Type | Description |
|-|-|
| None | A promise that resolves with a UTF-8-enconded string. |
[Tabelle : 19. Returns]

{#fetch.response-text__table_ijn_l2t_kdc} {#fetch.response-text__table_szf_1gs_kdc__entry__2}

| 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). {#fetch.response-text__ul_qpv_ggs_kdc} |
[Tabelle : 20. Exceptions]

{#fetch.response-text__table_szf_1gs_kdc}  
The following example shows how a simple way to use text() when the server returns plain text, like `Hello, world! This is a sample response`.

    const response = awaitfetch('https://example.com/text-endpoint');
    const text = await response.text();
    console.log(text); // Outputs: Hello, world! This is a sample response.

Output:

    Hello, world! This is a sample response.


