My puppeter Js code is not retrieving all external stylesheets, even though I need them for further processing. Here's what I have so far:
try {
const browser = await puppeteer.launch();
const page = await browser.newPage();
page.on('response', async response => { // There is no waiting here
if(response.request().resourceType() === 'stylesheet') {
resolve(response.text()); // Wait and resolve at this point
}
});
await page.goto(url);
await browser.close();
// Do not resolve here
} catch (e) {
return reject(e);
}
I'm encountering an issue where multiple external stylesheets are not being retrieved. How can I resolve this problem?
NOTE: I am using the resolve method because I require the stylesheets for subsequent processing and I need them to be returned.