Skip to main content
The Response class represents responses received by pages. Responses are emitted when the page receives an HTTP response for a request.

Methods

url

Returns the URL of the response.
Returns: string

ok

Returns whether the response was successful (status in the range 200-299).
Returns: boolean

status

Returns the HTTP status code.
Returns: number

statusText

Returns the HTTP status text.
Returns: string

headers

Returns the response headers.
Returns: Object
This method returns provisional headers. Use allHeaders() for actual headers received over the network.

allHeaders

Returns all response headers.
Returns: Promise<Object>

headersArray

Returns the response headers as an array of objects.
Returns: Promise<Array<{name: string, value: string}>>

headerValue

Returns the value of a specific header.
string
required
The header name (case-insensitive)
Returns: Promise<string | null>

headerValues

Returns all values of a specific header.
string
required
The header name (case-insensitive)
Returns: Promise<string[]>

body

Returns the response body as a Buffer.
Returns: Promise<Buffer>

text

Returns the response body as text.
Returns: Promise<string>

json

Parses the response body as JSON.
Returns: Promise<object>

request

Returns the request that initiated this response.
Returns: Request

frame

Returns the frame that initiated the request.
Returns: Frame

fromServiceWorker

Returns whether the response was served by a service worker.
Returns: boolean

finished

Waits for the response to finish loading.
Returns: Promise<null>

serverAddr

Returns the server IP address and port.
Returns: Promise<{ipAddress: string, port: number} | null>

securityDetails

Returns SSL and other security information.
Returns: Promise<Object | null>

httpVersion

Returns the HTTP version.
Returns: Promise<string>

Example Usage

Monitor API Responses

Check Response Status

Extract Response Headers

Wait for Specific Response