Answers for "chrome-aws-lambda"

0

chrome-aws-lambda

const chromium = require('chrome-aws-lambda'); exports.handler = async (event, context, callback) => {  let result = null;  let browser = null;   try {    browser = await chromium.puppeteer.launch({      args: chromium.args,      defaultViewport: chromium.defaultViewport,      executablePath: await chromium.executablePath,      headless: chromium.headless,      ignoreHTTPSErrors: true,    });     let page = await browser.newPage();     await page.goto(event.url || 'https://example.com');     result = await page.title();  } catch (error) {    return callback(error);  } finally {    if (browser !== null) {      await browser.close();    }  }   return callback(null, result);};
Posted by: Guest on December-07-2020

Code answers related to "Javascript"

Browse Popular Code Answers by Language