Help

Pagination implementation

Topic Labels: API
15780 11
cancel
Showing results for 
Search instead for 
Did you mean: 
Danny_Alvarez
5 - Automation Enthusiast
5 - Automation Enthusiast

Hi there! I’m getting a bunch of records using the API and I would like to paginate the results - in the end, I’d like to display to the user 10 records on a page, then when they hit ‘Next Page’ I can show them the next 10, and so on, requesting the next 10 from the server each time (as opposed to grabbing all the records myself and paginating them in the client).

I see that there is eachPage() and fetchNextPage(), but I may be confused about how they work. I use eachPage to get the records and massage the data I get by looping through the records. However, the done() function doesn’t seem to get called unless I call fetchNextPage() and I want to call fetchNextPage() after a user chooses to get to the next page of results. Any help/advice would be awesome!

11 Replies 11
Weiwei_Li
5 - Automation Enthusiast
5 - Automation Enthusiast

thanks for the reply! i didn’t know that caching was implemented.

You are correct that the offset property hasn’t been implemented for node.js, but I don’t think it is actually required based on Evan’s response here:

Issue: Offset property with node.js

opened by theweiweiway on 2019-04-30
Hi, I would like to use the offset property to paginate through records with Node.js. I understand it exists for curl,...

also, thanks for the great articles you have written on your blog. they have been very helpful.

I believe that I tried that approach, that is, trying to call fetchNextPage only when the user requires it but there are still challenges. In order to create the pagination markup that the tutorial is about you need to know the total number of records and pages and current page. You can’t do that when eachPage only gives you the first 100 but doesn’t tell you the total records.

And you can’t call fetchNextPage outside of the eachPage function so getting counts and current page in conjunction with calling fetchNextPage on the fly doesn’t seem possible but I could be wrong.

If you’re using the NodeJs client and found a better way, do share.

Also like he say Airtable isn’t for backend use per say and I was going to point that out when you mentioned 5000 record. If you app reaches that, it’s probably time to scale to firebase or mongodb. I just use Airtable for smaller projects.