Created
October 31, 2019 05:05
-
-
Save yusufsyaifudin/9c84f43c5654113185a8f896cec69234 to your computer and use it in GitHub Desktop.
Pagination
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
parameter from request = page and limit | |
so, | |
offset = (page - 1) * limit | |
but you need to check if page <= 0 then page = 1 | |
if limit <= 0 then set it to default minimum limit | |
If your request is only limit and offset, then you need to calculate the current page: | |
page = (limit + offset) / limit | |
but you need to check if offset < 0 then default to 0, and limit is must set to default minimum limit, let say = 25 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment