0

I have this working code (puppeteer) : 

async function extractedEvaluateCall(page) {
    await page.waitForXPath(xpath);
    const links = await page.$x(xpath);
    const results = await page.evaluate((...links) => {
      return links.map(e => e.innerText);
    }, ...links);
}

What does the notation ... does here ?

I tried without, it doesn't work:

UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON Are you passing a nested JSHandle?

links is already an array, why the need of spread operator ?

4
  • 1
    links is already an array, why the need of spread operator ? Commented May 21, 2021 at 22:51
  • 1
    It’ll destructure the array and pass the values as separate arguments to the function. Commented May 22, 2021 at 6:11
  • 2
    The first one is Rest parameters syntax and the second one is Spread syntax? Commented May 22, 2021 at 6:12
  • @fubar there is no destructuring here. One is rest syntax and the other is spread syntax. Commented May 22, 2021 at 6:14

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.