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