Skip to content

Latest commit

 

History

History
298 lines (217 loc) · 12.1 KB

File metadata and controls

298 lines (217 loc) · 12.1 KB
id class-apiresponse
title APIResponse

import Tabs from '@theme/Tabs'; import TabItem from '@theme/TabItem'; import HTMLCard from '@site/src/components/HTMLCard';

APIResponse class represents responses returned by apiRequestContext.get() and similar methods.


Methods

body {#api-response-body}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16apiResponse.body

Returns the buffer with response body.

Usage

await apiResponse.body();

Returns


dispose {#api-response-dispose}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16apiResponse.dispose

Disposes the body of this response. If not called then the body will stay in memory until the context closes.

Usage

await apiResponse.dispose();

Returns


headers {#api-response-headers}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16apiResponse.headers

An object with all the response HTTP headers associated with this response.

Usage

apiResponse.headers();

Returns


headersArray {#api-response-headers-array}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16apiResponse.headersArray

An array with all the response HTTP headers associated with this response. Header names are not lower-cased. Headers with multiple entries, such as Set-Cookie, appear in the array multiple times.

Usage

apiResponse.headersArray();

Returns


json {#api-response-json}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16apiResponse.json

Returns the JSON representation of response body.

This method will throw if the response body is not parsable via JSON.parse.

Usage

await apiResponse.json();

Returns


ok {#api-response-ok}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16apiResponse.ok

Contains a boolean stating whether the response was successful (status in the range 200-299) or not.

Usage

apiResponse.ok();

Returns


status {#api-response-status}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16apiResponse.status

Contains the status code of the response (e.g., 200 for a success).

Usage

apiResponse.status();

Returns


statusText {#api-response-status-text}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16apiResponse.statusText

Contains the status text of the response (e.g. usually an "OK" for a success).

Usage

apiResponse.statusText();

Returns


text {#api-response-text}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16apiResponse.text

Returns the text representation of response body.

Usage

await apiResponse.text();

Returns


url {#api-response-url}

<font size="2" style={{position: "relative", top: "-20px"}}>Added in: v1.16apiResponse.url

Contains the URL of the response.

Usage

apiResponse.url();

Returns