Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

If page is more than totalDocs then empty array #35

Closed
ruslanguns opened this issue Jul 11, 2019 · 4 comments
Closed

If page is more than totalDocs then empty array #35

ruslanguns opened this issue Jul 11, 2019 · 4 comments

Comments

@ruslanguns
Copy link

Describe the bug
If I am sending higher page returns empty array.

To Reproduce
Data object is the result from query using paginate-v2. As you can see limit is fine asking for more data in the query, the issue only happens with page (per_page).

Expected behavior
Should return last page available, or validation error.

Screenshots
image

Desktop (please complete the following information):

  • OS: Windows Node NestJS
@aravindnc
Copy link
Owner

@ruslanguns
You can always check hasPrevPage/NextPage OR totalPages to see if next page has data or not.

@ruslanguns
Copy link
Author

Can you please show me an example of this validation?

@aravindnc
Copy link
Owner

I mean do not snow page 2 if you get hasNextPage = false while getting response from page = 1.
ie.
if hasNextPage == true
then load next page
else stop loading further pages

@ruslanguns
Copy link
Author

Oh yes, I understand the work around, I am actually printing an Exception Error when someone is paging to pages that does not exists, however my guess it that the library should validate this arg with a default action as a default, for example, show the last page possible.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants