-
-
Notifications
You must be signed in to change notification settings - Fork 128
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
JSON Spec Pagination Support #31
Comments
Right now See here https://github.com/robsontenorio/vue-api-query#pagination // GET /users?sort=firstname&page=1&limit=20
let users = await User
.orderBy('firstname')
.page(1)
.limit(20)
.get() If you are using Laravel, there is a full support for pagination out-of-the-box by calling https://laravel.com/docs/5.7/pagination We have all necessary info to paginate here: // sample of response for paginate
{
"total": 50,
"per_page": 15,
"current_page": 1,
"last_page": 4,
"first_page_url": "http://laravel.app?page=1",
"last_page_url": "http://laravel.app?page=4",
"next_page_url": "http://laravel.app?page=2",
"prev_page_url": null,
"path": "http://laravel.app",
"from": 1,
"to": 15
} What would be advantages to use JSON API SPEC for pagination? Once this package does not follow this spec? |
For now, lets stick to default. If you can, please submit a PR. |
@loonpwn, not sure if you're still looking, but to accomplish this, I added the following to my base
Then, you can use the
|
cool! thanks! |
Since I did not see it in the readme, this is how you would do it with the merged PR and laravel-json-api-paginate parameterNames () {
return {
include: 'include',
filter: 'filter',
sort: 'sort',
fields: 'fields',
append: 'append',
page: 'page[number]',
limit: 'page[size]'
}
} |
Hi, great package really good 👍 Came across something that may be worth supporting.
The https://github.com/spatie/laravel-query-builder package has an alternative way of setting up the pagination where you install https://github.com/spatie/laravel-json-api-paginate and the pagination adheres to the JSON API spec.
The pagination supported in this plugin won't handle this out of the box, you can get around it by providing the custom params.
params({ 'page[number]': page, 'page[limit]': limit })
Ideally there would be a toggle to switch to this mode or some way to globally customize the param names used by the Parser to handle it.
The text was updated successfully, but these errors were encountered: