Resource

Resources are all network assets loaded to render a page, including CSS, Javascript, Fonts, Web Sockets, XHR/Fetch Requests, and more.

The Resource class is returned from window.waitForResource calls. It is used to dynamically load portions of a Resource on demand.

If an obtained Resource is a Websocket, a WebsocketResource is returned.

Properties

request

Retrieve the network request used to retrieve this resource.

ReturnsResourceRequest

response

Retrieve the network request used to retrieve this resource.

ReturnsResourceResponse

url

The requested url

Returnsstring

type

The type of resource. Possible values are: Document, Redirect, Websocket, Ico, Preflight, Script, Stylesheet, Xhr, Fetch, Image, Media, Font, Text Track, Event Source, Manifest, Signed Exchange, Ping, CSP Violation Report, Other

ReturnsResourceType

isRedirect

Was this request redirected

Returnsboolean

data

Load the underlying buffer returned by this network response.

ReturnsPromise<Buffer>

Methods

text()

Convert the returned resource body to a string.

ReturnsPromise<string>

json()

Convert the returned resource body into json.

ReturnsPromise<json>

Edit this page on GitHub