I am trying to access a variable that i declared inside in an async function. Like this:
exports.startTheBasketEngine = async (username, password, domainData) => {
const parse = domainData.auctionUrl.split("-")
var domainName = parse[0]
const stringIsIncluded = await page.evaluate(() => {
console.log(domainName)
});
}
The console.log line is returning that error:
UnhandledPromiseRejectionWarning: Error: Evaluation failed: ReferenceError: domainName is not defined
How can i resolve this problem?
I assume you use Puppeteer.
According to the docs, the .evaluate()
takes more arguments. All arguments, starting from the second, will be passed to the pageFunction
. So try something like this:
var domainName = parse[0]
const stringIsIncluded = await page.evaluate((dName) => {
console.log(dName);
}, domainName);
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments