collection and type filter the page you got, not the whole catalogue.Filtering happens after the page is fetched. So a page of 50 products containing
3 digital ones returns count: 3 while hasMore is still true — and an empty
page doesn’t mean there are no more matches.Page until hasMore is false and accumulate. Never stop on a short page.
Paginating with a filter
async function allProducts(params = {}) { const out = []; let cursor = null; do { const qs = new URLSearchParams({ ...params, limit: '100', ...(cursor ? { cursor } : {}) }); const res = await fetch(`https://exclusivo.one/api/v1/products?${qs}`, { headers: { Authorization: `Bearer ${process.env.EXC_API_KEY}` }, }); const { data, pagination } = await res.json(); out.push(...data); cursor = pagination.hasMore ? pagination.nextCursor : null; } while (cursor); // not: while (data.length) return out;}