REST API nextPageKey parameter

  • Goal: The goal is to create a JS that returns all records from a paginated REST API query.

  • Steps: I have setup a REST API query called getTransactions. This returns max 50 records. The nextPageKey` parameter can be used as a query parameter to fetch the next set of transactions. This key is only provided if more than 50 transactions are present.

  • Details:
    The JS I have to collect all records does not show any output.

  • Screenshots:

Hi @SanderL,

Have a look at this post, which covers the same thing. You might just need to return await fetchAll() since you're likely returning early before any data is actually fetched.

Hi MikeCB,

Thanks. I have added await in the js query:
return await fetchAll();

The output after running the JS query:

  • 0:undefined
  • 1:undefined

I have found the issue. The issue is that getTransactions returns transactions under the key "transactions", but my script is expecting "records".

The adjusted script:

Good find, @SanderL! And welcome back to the community. :slightly_smiling_face: