#community-help

How to Check Next Page Existence When Paginating

TLDR Patrik inquired about checking next page when paginating. Jason suggested using the 'found' field from the response and 'per_page' query value.

Powered by Struct AI

1

1

3
12mo
Solved
Join the chat
Oct 22, 2022 (12 months ago)
Patrik
Photo of md5-1e5d7ffd1cc67805b3b347e7edaa1b1d
Patrik
06:28 PM
Hi everyone! Is there any way to check if there is next page when paginating? Or only one way is to request next page for example with limit 1? Thank you!

1

Jason
Photo of md5-8813087cccc512313602b6d9f9ece19f
Jason
06:29 PM
There is a field called found in the response which is the total number of results for that query. You can use that and the per_page value you set in the query to get total number of pages.
Patrik
Photo of md5-1e5d7ffd1cc67805b3b347e7edaa1b1d
Patrik
06:31 PM
Aha! great to know, thank you for fast response! Im working with TS second day yet, but really love it! Especially in comparison with ES 💪

1