0

Let's say you have some data that is fetched from an api. It all comes in in one chunk, unpaginated. I am using vercel's SWR library. Is there a way to paginate this data client-side? useSWRInfinite relies on the fact that the link that you provide to it will have the ?page={pageNumber} query.

juliomalves
  • 42,130
  • 20
  • 150
  • 146
Luca Adrian
  • 75
  • 1
  • 7

1 Answers1

1

Not sure if I understood you correctly, but if you have unpaginated data when the request is done, do you mean that you have all the data from the API?

If that is the case, why don't you just write the pagination logic?

So you are already holding all the data in some variable I assume, use that data to create pagination. Create the state variable and just do the math so its value changes based on the selected page, there are multiple examples of that.

juliomalves
  • 42,130
  • 20
  • 150
  • 146
  • 2
    You understood correctly. I just wanted to make sure that there isn't any way to get paginated data from an api that has gives out unpaginated data. After I've slept I understood that my question was pretty nonsensical – Luca Adrian Feb 05 '22 at 15:43