Pagination

Cursor pages for lists.

Lists answer a page at a time with a cursor:

{
  "items": [ /* … */ ],
  "nextCursor": "dabe0026-3fbe-427e-afc3-7c509f68d462"
}

Pass nextCursor back as cursor for the next page. null means there is none.

Prop

Type

Every product, page by page
async function allProducts(key) {
  const items = [];
  let cursor = null;
  do {
    const url = new URL('https://api.cashiar.app/v1/storefront/products');
    url.searchParams.set('limit', '100');
    if (cursor) url.searchParams.set('cursor', cursor);
    const res = await fetch(url, { headers: { Authorization: `Bearer ${key}` } });
    const page = await res.json();
    items.push(...page.items);
    cursor = page.nextCursor;
  } while (cursor);
  return items;
}

Keep the same filters (q, collection, sort) on every page of one list.