UNPKG

@fastly/as-fetch

Version:

![npm version](https://img.shields.io/npm/v/@fastly/as-fetch) ![npm downloads per month](https://img.shields.io/npm/dm/@fastly/as-fetch)

165 lines (87 loc) 2.49 kB
[@fastly/as-fetch](../README.md) / Response # Class: Response A [Fetch `Response`](https://developer.mozilla.org/en-US/docs/Web/API/Response) Object. ## Hierarchy - [Body](body.md) ↳ **Response** ## Table of contents ### Constructors - [constructor](response.md#constructor) ### Accessors - [bodyUsed](response.md#bodyused) - [headers](response.md#headers) - [ok](response.md#ok) - [status](response.md#status) - [statusText](response.md#statustext) - [url](response.md#url) ### Methods - [arrayBuffer](response.md#arraybuffer) - [text](response.md#text) ## Constructors ### constructor • **new Response**(`body`, `init`) Constructor for an HTTP response. #### Parameters | Name | Type | Description | | :------ | :------ | :------ | | `body` | ``null`` \| `ArrayBuffer` | The initial content of the response Body. | | `init` | [ResponseInit](responseinit.md) | The Request configuration object. | #### Overrides [Body](body.md).[constructor](body.md#constructor) ## Accessors ### bodyUsed`get` **bodyUsed**(): `boolean` #### Returns `boolean` A boolean representing whether the Body has been consumed already or not. ___ ### headers`get` **headers**(): [Headers](headers.md) Get the `Response` headers. #### Returns [Headers](headers.md) A `Headers` object of the HTTP response headers, for the `Request`. ___ ### ok`get` **ok**(): `boolean` Get if the response was ok/successful. #### Returns `boolean` a boolean that is true if the response was successful, false if not. ___ ### status`get` **status**(): `number` Get the HTTP status of the response. #### Returns `number` an unsigned 16 bit integer of the status code. ___ ### statusText`get` **statusText**(): `string` Get the text assosciated with the status code of the response. #### Returns `string` a string associated with the status text for the response status code. ___ ### url`get` **url**(): `string` Get the URL of where the response came from. #### Returns `string` a string of the URL. ## Methods ### arrayBuffer ▸ **arrayBuffer**(): ``null`` \| `ArrayBuffer` #### Returns ``null`` \| `ArrayBuffer` an `ArrayBuffer` for the Body content (if it contains one). #### Inherited from [Body](body.md).[arrayBuffer](body.md#arraybuffer) ___ ### text ▸ **text**(): `string` #### Returns `string` a string representation of the Body `ArrayBuffer` content. #### Inherited from [Body](body.md).[text](body.md#text)