takeScreenshotWhen
takeScreenshotWhen is an optional property that defines when to take screenshot based on how the page is loaded. By default is set to load.
The available options are:
loadit considers operation to be finished when the load event is fired.domcontentloadedit considers operation to be finished when the DOMContentLoaded event is fired.networkidleit considers operation to be finished when there are no network connections for at least 500ms.commitit considers operation to be finished when network response is received and the document started.
api/routes/screenshot.ts
const { UrlToImage } from '@url2image/sdk'
const { data, success, message } = await UrlToImage({
url: 'URL_TO_SCREENSHOT',
token: 'YOUR_API_KEY',
options: {
takeScreenshotWhen: 'domcontentloaded'
}
})