Skip to content

Documentation

JavaScript SDK: Response: website response

HTTP client methods return a Response. Its status, body, headers, finalUrl, fromCache, durationMs, and snapshotUuid fields need no additional request.

Each example is a separate fragment inside async function run(ctx). Use await only for methods whose signature returns a Promise.

Obtaining the object

const response = await ctx.http().get(ctx.param('catalog_url', 'https://example.com/catalog'));

Methods

ok

response.ok() → boolean

Check that the HTTP status is between 200 and 299 and the response is not a detected CAPTCHA challenge. An HTTP 200 challenge page does not mean the requested data is available.

const result = response.ok();

dom

response.dom() → Dom

Parse the response body as HTML, using the final URL after redirects.

const result = response.dom();

json

response.json(text) → unknown

Parse the response body as JSON.

const result = response.json();

header

response.header(name) → string | null

Get a response header without regard to the letter case of its name.

const result = response.header('Content-Type');