Skip to main content
Question

Pagination - How can I store and provide a non-numeric page identifier?


(Also posted at https://stackoverflow.com/questions/62351427/pagination-how-can-i-store-and-provide-a-non-numeric-page-identifier)

I am trying to add pagination to my Zapier trigger.

The API I am using for the trigger supports pagination, but not using a page number in the traditional sense (ie. page 1,2,3,...). Instead, the API response includes a key (ie. "q1w2e3r4") which should be passed as a parameter to the next request to get the next page of results.

From looking at the docs, I can use {{bundle.meta.page}} (which defaults to 0 unless otherwise set).

I am trying to set {{bundle.meta.page}} in the code editor, with an example shown below:

const options = {
  url: 'company_xyz.com/api/widgets',
  method: 'GET',
  ...,
  params: {
    ...,
    'pagination_key': bundle.meta.page,
  }
}

return z.request(options)
  .then((response) => {
    response.throwForStatus();
    const json_response = response.json;

    widgets = json_response.widgets
    ...

    bundle.meta.page = json_response["next_pagination_key"]

    return widgets;
  });

The problem is that when Zapier tries to retrieve the next page, bundle.meta.page will be 1 instead of the value of next_pagination_key from the result of the previous request.

Is there something that I am doing incorrectly? Is there another variable where I should set next_pagination_key?

Did this topic help you find an answer to your question?
This post has been closed for comments. Please create a new post if you need help or have a question about this topic.

3 replies

steph.n
Forum|alt.badge.img+8
  • Builder
  • 899 replies
  • June 26, 2020

Hi @jamesanselm - Thanks for writing into our community! I’ve went ahead and escalated your ticket to our Support team since they may be of help to you given the technical aspect of your question. Please stand by!


  • Author
  • Beginner
  • 7 replies
  • June 29, 2020

I had responded to the StackOverflow question with the error that I encountered next, but the developer did not respond. 

 

https://stackoverflow.com/questions/62351427/pagination-how-can-i-store-and-provide-a-non-numeric-page-identifier


Danvers
Forum|alt.badge.img+12
  • Zapier Staff
  • 3731 replies
  • June 29, 2020

Hi @jamesanselm, I’m sorry that you didn’t have any luck on Stack Overflow. I’m going to re-open your ticket with the Support Team and see if there’s anything else that we can help you with on this one.