'Amazon Scrape returning undefined nightmare package

I am using nightmare.js to get the price for all the products in the database. When I try running just

  const data = await monitor.find({})
  data.forEach(async (monitor1) => {
    const url = monitor1.Link
    console.log(url)
  })

It works, and console.logs many links, but when I try

 data.forEach(async (monitor1) => {
    const url = monitor1.Link
    console.log(url)
     try {
      const priceString =  await nightmare.goto(monitor1.Link)
                                         .wait(".a-price-whole")
                                         .evaluate(() => document.getElementsByClassName("a-price-whole").innerText)
                                         .end()
      console.log(priceString)
    } catch (e) {
      throw e
    }
  
  })

It returns undefined for all the prices. The class is called a-price-whole as shown here enter image description here

Why is this happening?



Solution 1:[1]

Information is less, but I believe you are using same nightmare instance. Refer this answer

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 devilpreet