PAGY with Rails API Only
Hi All,
I've built a Rails API and have a separate Nuxt/Vue app for my front end. Looking to add server side pagination with Pagy and was wondering how i best to call the next 'X' number of results.
Pagy is working fine and giving me my first 20 records, but to call the next 20 I'm a little confused. Do i need to specify the URL from the front end as in 'localhost:3000/contacts?page=2' and send that, or can i pass some params like [:next] as mentioned in the docs. Has anyone had success with this or has an example?
Cheers
Tim
Hey Tim,
Normally, you want to pass the next page number into the URL like you mentioned. That's how pagination links work when you display render them. Then the server knows which group of 20 records to grab next.
Perfect, thanks for the response Chris. It'll be sinmple to write a ?page=X +1 type method as the page comes in the header of the response. I could also utlise the 'link' from the header.... I'll have a play :)