Skip to main content

(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_responsep"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?

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!


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


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.