Skip to main content
Using Deno in production at your company? Earn free Deno merch.
Give us feedback
Go to Latest
method HTTPRequest.prototype.respond
Re-export
import { HTTPRequest } from "https://deno.land/x/puppeteer@14.1.1/vendor/puppeteer-core/puppeteer/api-docs-entry.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>