Options
Take Screenshot When

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:

  • load it considers operation to be finished when the load event is fired.
  • domcontentloaded it considers operation to be finished when the DOMContentLoaded event is fired.
  • networkidle it considers operation to be finished when there are no network connections for at least 500ms.
  • commit it 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'
    }
})