Options

The getHtml function accepts an optional options object as its second parameter. This object allows you to customize the behavior of Waterfall-Fetch.

const result = await getHtml("https://example.com", options);

Options Object

Options is an optional parameter you can pass, you can define:

  • set The set of strategies that will be used, order sensitive,
  • evalFunction
type Options = {
	set: "cheap" | "js" | null;
	evalFunction?: OnPageEvaluationFunction;
};

Properties

set
string

Specifies the strategy set to use. Can be “cheap”, “js”, or null (default).

evalFunction
function

A custom evaluation function to be executed in the context of the page (only applicable when using Puppeteer).

Usage Example

import getHtml from "waterfall-fetch";

const url = "https://example.com";

const options = {
	set: "js",
	evalFunction: async (page) => {
		return await page.evaluate(() => document.title);
	},
};

const result = await getHtml(url, options);

For more information on using custom evaluation functions, see the Evaluation Functions guide.