I am not much skilled with JS. I want to pass the "i" variable (page's number) in the hash. I tried this but it says
Error: Evaluation failed: ReferenceError: i is not defined
async function searchResults(domain, keyword) {
let [page, browser] = await initPuppeteer(domain)
let products = []
for (let i = 1; i <= 2; i++) {
let url = `https://www.example.com/test?page=${i}`
await page.goto(url)
let products_page = await page.$$eval(
'[data]',
divs => divs.map( div => ({
page: i <--- Need to access the outer loop iterator here
})
)
);
asins.push(products_page)
}
await browser.close();
return products.flat()
}