Skip to content

Commit

Permalink
Add ignore_host_errors and wait_until options
Browse files Browse the repository at this point in the history
  • Loading branch information
krasun committed Nov 26, 2023
1 parent 033d02e commit c1f9968
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "screenshotone-api-sdk",
"homepage": "https://screenshotone.com",
"version": "1.1.7",
"version": "1.1.8",
"description": "Use ScreenshotOne.com API to generate screenshots of any website.",
"repository": {
"type": "git",
Expand Down
32 changes: 32 additions & 0 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -380,6 +380,38 @@ export class TakeOptions {
return this;
}

/**
* When the site responds within the range of 200-299 status code,
* you can ignore errors and take a screenshot of the error page anyway.
* To do that, set the option ignore_host_errors to true.
* It is false by default.
*
* It is helpful when you want to create a gallery of error pages or,
* for some reason, you need to render error pages.
*/
ignoreHostErrors(ignore: boolean): TakeOptions {
this.put("ignore_host_errors", ignore ? "true" : "false");

return this;
}

/**
* Use wait_until to wait until an event occurred before taking a screenshot or rendering HTML or PDF.
*
* The default value of wait_until is ['load']. Allowed values are:
* - load: the navigation is successful when the load even is fired;
* - domcontentloaded: the navigation is finished when the DOMContentLoaded even is fired;
* - networkidle0: the navigation is finished when there are no more than 0 network connections for at least 500 ms;
* - networkidle2: consider navigation to be finished when there are no more than 2 network connections for at least 500 ms.
*
* The parameter accepts many values. It means that screenshots will be taken after all events occur altogether.
*/
waitUntil(...until: string[]): TakeOptions {
this.put("wait_until", ...until);

return this;
}

/**
* Sets IP country code.
*/
Expand Down

0 comments on commit c1f9968

Please sign in to comment.