Pagination for Query with No Total Records Count

I'm using the Onfleet API, which returns 64 results. If "lastID" is returned in the response data, more results exist and this should be used as a URL parameter to paginate results via another query. I'm confused as to how to go about this.

Using it in the original API call creates a dependency cycle and errors. I've tried setting a state variable, but I don't see a viable option when using a second, separate API call to update the main table. I've tried all kinds of other workarounds with server-side pagination (using the new table component), a pagination component, and more, all to no avail.

Does anyone know the proper way for this scenario to be handled? Thanks in advance!

From the Onfleet documentation:

Each request will return up to 64 tasks but may return fewer and still include a lastId . lastId will be missing from the response once the last page of the results has been reached, so if the lastId is present, you should continue to paginate through the results. To walk through the pagination of all tasks from the from timestamp, append another query parameter of lastId=<lastId_from_previous_response> to your HTTP request.

all_deliveries query populates deliveriesTable.

After re-reading, I've tried the following to no avail:

  • Set the Next Cursor on deliveriesTable as {{}}

  • all_deliveries query with lastID URL parameter set to {{deliveriesTable.pagination.afterCursor}}.

When I try to paginate, nothing happens with the data in the table, but the page number advances to 2. What am I missing?

Hey @vinnie!

Apologies for the late reply here, but it looks as though you were able to get things worked out by switching the lastID parameter to lastId - is that correct?

Let me know if I'm missing anything! And thanks for posting such thorough context :slightly_smiling_face:

Yes, apologies! Meant to come back here and post the answer I received from emailing support!

It's amazing how these tiny mistakes can cause such a huge disruption for days on end - it's a recurring theme in my life.

:joy: mine as well, you're definitely not alone there.

1 Like