> ## Documentation Index
> Fetch the complete documentation index at: https://docs.qu.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# FetchResponse

The response for a FetchRequest.

## Implements

* `Iterable`\<\[`string`, `string`]>

## Accessors

### body

```ts theme={null}
get body(): null | Readonly<Uint8Array>
```

The response body, or `null` if there was no body.

#### Returns

`null` | `Readonly`\<`Uint8Array`>

#### Source

[utils/fetch.ts:891](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L891)

***

### bodyJson

```ts theme={null}
get bodyJson(): any
```

The response body, decoded as JSON.

An error is thrown if the body is invalid JSON-encoded data or if there was no body.

#### Returns

`any`

#### Source

[utils/fetch.ts:916](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L916)

***

### bodyText

```ts theme={null}
get bodyText(): string
```

The response body as a UTF-8 encoded string, or the empty string (i.e. `""`) if there was no body.

An error is thrown if the body is invalid UTF-8 data.

#### Returns

`string`

#### Source

[utils/fetch.ts:900](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L900)

***

### headers

```ts theme={null}
get headers(): Record<string, string>
```

The response headers. All keys are lower-case.

#### Returns

`Record`\<`string`, `string`>

#### Source

[utils/fetch.ts:884](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L884)

***

### request

```ts theme={null}
get request(): null | FetchRequest
```

The request made for this response.

#### Returns

`null` | [`FetchRequest`](/sdk/content/classes/FetchRequest)

#### Source

[utils/fetch.ts:1033](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L1033)

***

### statusCode

```ts theme={null}
get statusCode(): number
```

The response status code.

#### Returns

`number`

#### Source

[utils/fetch.ts:870](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L870)

***

### statusMessage

```ts theme={null}
get statusMessage(): string
```

The response status message.

#### Returns

`string`

#### Source

[utils/fetch.ts:877](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L877)

## Methods

### assertOk()

```ts theme={null}
assertOk(): void
```

Throws a `SERVER_ERROR` if this response is not ok.

#### Returns

`void`

#### Throws

If the response is not ok.

#### Source

[utils/fetch.ts:1049](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L1049)

***

### getHeader()

```ts theme={null}
getHeader(key): string
```

Get the header value for `key`, ignoring case.

#### Parameters

| Parameter | Type     | Description                 |
| :-------- | :------- | :-------------------------- |
| `key`     | `string` | The header key to retrieve. |

#### Returns

`string`

The header value.

#### Source

[utils/fetch.ts:1016](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L1016)

***

### hasBody()

```ts theme={null}
hasBody(): this is FetchResponse & Object
```

Returns true if the response has a body.

#### Returns

`this is FetchResponse & Object`

True if the response has a body.

#### Throws

If the body is invalid UTF-8 data.

#### Source

[utils/fetch.ts:1026](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L1026)

***

### makeServerError()

```ts theme={null}
makeServerError(message?, error?): FetchResponse
```

Return a Response with matching headers and body, but with an error status code (i.e. 599) and `message` with an
optional `error`.

#### Parameters

| Parameter  | Type     | Description               |
| :--------- | :------- | :------------------------ |
| `message`? | `string` | The error message to use. |
| `error`?   | `Error`  | The error to use.         |

#### Returns

[`FetchResponse`](/sdk/content/classes/FetchResponse)

The error response.

#### Source

[utils/fetch.ts:975](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L975)

***

### ok()

```ts theme={null}
ok(): boolean
```

Returns true if this response was a success statusCode.

#### Returns

`boolean`

#### Source

[utils/fetch.ts:1040](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L1040)

***

### throwThrottleError()

```ts theme={null}
throwThrottleError(message?, stall?): never
```

If called within a [request.processFunc](FetchRequest-processFunc) call, causes the request to retry as if
throttled for `stall` milliseconds.

#### Parameters

| Parameter  | Type     | Description                                          |
| :--------- | :------- | :--------------------------------------------------- |
| `message`? | `string` | The error message to use.                            |
| `stall`?   | `number` | The number of milliseconds to stall before retrying. |

#### Returns

`never`

#### Throws

If `stall` is not a non-negative integer.

#### Source

[utils/fetch.ts:996](https://github.com/dominant-strategies/quais.js/blob/c1c12d43f9d34c6baad2b0542bd6d0acd6fefcbf/src/utils/fetch.ts#L996)
