Im learning how to use Puppeteer and the case is that when i try to map my data array object i can´t do it using the map function. is there a way map it with async/await or is there another way?
const puppeteer = require("puppeteer");
module.exports.screenshot = async (req, res) => {
let data = [
{ url: "someurl1", src: "someplace1" },
{ url: "someurl2", src: "someplace1" }
];
let browser = await puppeteer.launch();
let page = await browser.newPage();
try {
let files = data.map(info => (
await page.goto(info.url) //here i can´t await
await page.screenshot({ path: info.src }) //these two functions
));
await browser.close();
res.send({
data: files
})
} catch (error) {
console.error(`An error has occurred ${error}`);
}
}