Latest
method HTTPRequest.prototype.respond
import { HTTPRequest } from "https://dotland.deno.dev/x/puppeteer@16.2.0/vendor/puppeteer-core/puppeteer/types.d.ts";

Fulfills a request with the given response.

Examples

An example of fulfilling all requests with 404 responses:

await page.setRequestInterception(true);
page.on('request', request => {
  request.respond({
    status: 404,
    contentType: 'text/plain',
    body: 'Not Found!',
  });
});

NOTE: Mocking responses for dataURL requests is not supported. Calling request.respond for a dataURL request is a noop.

Parameters

response: Partial<ResponseForRequest>
  • the response to fulfill the request with.
optional
priority: number
  • If provided, intercept is resolved using cooperative handling rules. Otherwise, intercept is resolved immediately.

Returns

Promise<void>