class: Response

class: Response

Response class represents responses which are received by page.

  • response.body()
  • response.finished()
  • response.frame()
  • response.headers()
  • response.json()
  • response.ok()
  • response.request()
  • response.status()
  • response.statusText()
  • response.text()
  • response.url()

response.body()

  • returns: <Promise “Promise”)<Buffer ”Buffer“)>> Promise which resolves to a buffer with response body.

response.finished()

  • returns: <Promise “Promise”)<?Error ”Error“)>> Waits for this response to finish, returns failure error if request failed.

response.frame()

  • returns: <Frame> A Frame that initiated this response.

response.headers()

  • returns: <Object “Object”)> An object with HTTP headers associated with the response. All header names are lower-case.

response.json()

  • returns: <Promise “Promise”)<Object ”Object“)>> Promise which resolves to a JSON representation of response body.

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

response.ok()

  • returns: <boolean “Boolean”)>

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

response.request()

  • returns: <Request> A matching Request object.

response.status()

  • returns: <number “Number”)>

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

response.statusText()

  • returns: <string “String”)>

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

response.text()

  • returns: <Promise “Promise”)<string ”String“)>> Promise which resolves to a text representation of response body.

response.url()

  • returns: <string “String”)>

Contains the URL of the response.