← Back to Fetch domain

Fetch.getResponseBody

Causes the body of the response to be received from the server and returned as a single string. May only be issued for a request that is paused in the Response stage and is mutually exclusive with takeResponseBodyForInterceptionAsStream. Calling other methods that affect the request or disabling fetch domain before body is received results in an undefined behavior. Note that the response body is not available for redirects. Requests paused in the _redirect received_ state may be differentiated by `responseCode` and presence of `location` response header, see comments to `requestPaused` for details.

Domain: Fetch stable

Parameters

NameTypeDescription
requestIdRequestIdIdentifier for the intercepted request to get body for.

Returns

NameTypeDescription
bodystringResponse body.
base64EncodedbooleanTrue, if content was sent as base64.

Example Request

{
  "id": 1,
  "method": "Fetch.getResponseBody",
  "params": {
    "requestId": "request-1"
  }
}

Example Response

{
  "id": 1,
  "result": {
    "body": "body-value",
    "base64Encoded": true
  }
}

Usage in Node.js

const result = await send('Fetch.getResponseBody', {"requestId": "request-1"});
console.log(result);
// {"body": "body-value", "base64Encoded": true}