#community-help

Pagination and Determining Next Page

TLDR Gustavo asked about pagination and determining the next page. Jason suggested using the found, per_page, and page keys to calculate the total number of pages.

Powered by Struct AI
Jun 14, 2023 (6 months ago)
Gustavo
Photo of md5-f930fdb99fd46477205fa1201164ea50
Gustavo
04:46 PM
Regarding pagination, what's the recommended way to know if there's a next page?
Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
04:49 PM
The response will contain a found key with the total number of documents across all pages.
04:49
Jason
04:49 PM
You’d use that along with the per_page and page search parameters to determine the total number of pages
Gustavo
Photo of md5-f930fdb99fd46477205fa1201164ea50
Gustavo
04:50 PM
Thanks, will do that. It only works though if per_page is always the same. One could want to have the first page have fewer items to load faster, and in that case it would involve a bit more math, so a has_more could be nice. But your suggestion will work for me.