Pagination doesn't work #4363
Unanswered
BolotnikovMS
asked this question in
Help
Replies: 2 comments 2 replies
-
Hey there! Are you certain you have both a Also - you can provide formatted code examples using Markdown's three backticks and a lang code (```ts), which will look like the below: const page = 1
const limit = 10
const posts = await Post.query().paginate(page, limit) |
Beta Was this translation helpful? Give feedback.
1 reply
-
You should have some validation for the const limit = Math.min(100, request.input('limit', 10)); // if no limit is passed then default will be 10, if limit is bigger then 100 then Math.min will return 100, so you restrcit max value by 100;
const page = request.input('page', 1); // same here
const posts = await Post.query().paginate(page, limit) |
Beta Was this translation helpful? Give feedback.
1 reply
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all. When I try to do pagination, nothing happens Adonis 6 ((( Example code:
const posts = await Post.query()
.if(page && limit, (query) => query.paginate(page, limit))
Beta Was this translation helpful? Give feedback.
All reactions