Basically I'm trying to pass the "Browser" variable on to my main function, to pass on to "CheckStock". I've tried many thing but just can't seem to find a way how to do this. If anyone knows how to, please let me know. Thanks in advance! :)
// STARTUP BROWSER & GO TO URL
async function openBrowser(monitorURL) {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.goto(monitorURL)
return browser, page;
}
/*
...
...
...
other code
...
...
...
*/
// MAIN FUNCTION
async function monitor(monitorURL){
const page = await openBrowser(monitorURL);
await checkStock(page, browser)
}
You need to change how you return the two values to this (so they are both available in a returned object):
async function openBrowser(monitorURL) {
const browser = await puppeteer.launch({headless: false});
const page = await browser.newPage();
await page.goto(monitorURL)
return {browser, page};
}
And, then how you get them both out of that object:
// MAIN FUNCTION
async function monitor(monitorURL){
const {page, browser} = await openBrowser(monitorURL);
await checkStock(page, browser);
}
この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。
侵害の場合は、連絡してください[email protected]
コメントを追加