const customerDetails = await Customer.search({
session,
query: req.query.search ? req.query.search : null,
limit: 50,
// Nothing seems to work here to paginate, nor is there any documentation surrounding this feature on this specific client
});
The limit is only 250 customers and I need to be able to paginate through a few thousand.
I’m having issues with this pagination too, I’ve made a nodejs and express app that can request products on an endpoint and wanted to perform the paginated request for the second page, but I can’t manage the way client-side can tell my backend to request the next page
I’ve tried to make a GET request on the link given by the API from the headers but I’ve a CORS error
Does someone know anything ? The documentation is too general about pagination and there is no example
Below is an working example to fetch all inventory levels by location ids. But I think other pagination should be similar. Hope it still helps after one year. LOL
async getAllInventoryLevelsByLocationIds(locationIds: string[]):Promise<InventoryLevel[]> {
const session = this.getSession();
let result:InventoryLevel[] = [];
// Get the first page
let response = await this.shopify.rest.InventoryLevel.all({
session,
location_ids: locationIds.join(','),
limit: 250
});
result = result.concat(response.data);
// Get the following pages. Can NOT pass in location_ids to get next pages
let nextPageInfo = response.pageInfo?.nextPage?.query?.page_info;
while(nextPageInfo) {
response = await this.shopify.rest.InventoryLevel.all({
session,
limit: 250,
page_info: nextPageInfo,
});
result = result.concat(response.data);
nextPageInfo = response.pageInfo?.nextPage?.query?.page_info;
}
return result;
}