First page has prev link in pagination

SilviaBao
Just browsing

First page has prev link in pagination

Hi,

 

First page shouldn't return prev in the link header. This is how I replicate it.

E.g. 
1. Get networks, 1st page, return expected results

 

2. Get 2nd page, return expected result  

 

 

3. Go back to previous page, 1st page, return same results as the first request but in descending order

 

 

 

 

4. as I receive the prev in the link, send that request 

2 REPLIES 2
sungod
Head in the Cloud

I'd say the effect you are seeing is due to the API being stateless - all it sees is the parameters in your latest call, there's no 'memory' of the previous call - i.e. at step 3 the API does not 'know' it is what you call page 1, it is simply a page.

 

So if you want to follow 'prev' links for this call, I would check for empty response and stop there.

 

Pagination details do vary a bit depending on the API call involved, I've learned that different calls may need different handling to detect when to stop in order to prevent long/endless loops.

 

Thanks for your answer. I believe it was not working in the way it's now. When I started to play around their pagination, getting the first page not giving me the 'prev' link.

I have tested the other endpoint 'vpn/statues', request for the 'prev' from the first page is returning a full list of all the statues no matter what is the number 'perPage' is set, instead of returning an empty result. I believe it is a bug.

Get notified when there are additional replies to this discussion.