How to paginate in API routes ?
Unanswered
Gordiac posted this in #help-forum
GordiacOP
I wrote a request and it returns a lot of data, so I want to make the pagination function and use it for both mobile side and web side .
13 Replies
@Gordiac I wrote a request and it returns a lot of data, so I want to make the pagination function and use it for both mobile side and web side .
you can use for example searchParams so enter a specific page or use a pagination token. Use that, what suite more your case. Then read the searchparams inside your route handler and return only a bunch of data for the specific page/pagination token
@Gordiac solved?
@B33fb0n3 <@277395588289396737> solved?
GordiacOP
I guess I'm still looking.
@Gordiac I guess I'm still looking.
I guess there won't be a second answer :/
@B33fb0n3 I guess there won't be a second answer :/
GordiacOP
I actually use firestore, as far as I know it had such a feature.
@Gordiac I actually use firestore, as far as I know it had such a feature.
normally a backend should have these kind of features yea...
But you need to build the stuff around it. And that's this part: https://nextjs-forum.com/post/1253982030123761715#message-1253987179823366155
@Gordiac I actually use firestore, as far as I know it had such a feature.
Longtail tuna
use
startAfter and limit thenbut searchParams/state is still needed to track displayed data
@B33fb0n3 normally a backend should have these kind of features yea...
GordiacOP
but in this case I would have built a proxy, that's why I use the api routes in the next js project to access both mobile and web
@Gordiac but in this case I would have built a proxy, that's why I use the api routes in the next js project to access both mobile and web
I thought firebase is your backend? And you backend should be somehow accessable. Normally though api endpoints. And these api endpoints exists from your provider (firebase)
@B33fb0n3 I thought firebase is your backend? And you backend should be somehow accessable. Normally though api endpoints. And these api endpoints exists from your provider (firebase)
GordiacOP
I actually define api routes in next js and forward the data to firebase and I will write the exact same process for the mobile version, in short, I do not have a common backend api route