#Dev-Ahmed-Hasnain-pagination

1 messages · Page 1 of 1 (latest)

swift belfry
#

Hey, I guess you'd persist the next_page value of the previous request somewhere in your application state and that can act as a 'back'

kind saddle
#

i did that, in the 1st call i am not sending any next page parameter as mentioned by stripe, in the next call if there is a next page if will sent the id in the response, i save that id in the nextPage variable, and send this in the next request which gives another nextPage if there is one, so i save the nextPage id in previousPage and the new id as the nextPage id, but when pagination ends it will return null as next_page then problem starts, now when is send previousPage id as a parameter in the call it will return me the next id which is null.

vocal ledge
#

Hi! I'm taking over this thread.

kind saddle
#

ok thanks

vocal ledge
#

but when pagination ends it will return null as next_page then problem starts
If there is no next page, then it's expected that the next_page is null.

If you want to be able to go back in the pagination, you have two main options: store next_page value of the previous request as ynnoj mentioned. Or use the ending_before parameter https://stripe.com/docs/api/pagination#pagination-ending_before

kind saddle
#

i have used that too and it is working fine thank you, but i am now working on search api. please guide me about this.

#

backword pagination in search api.

vocal ledge
#

Oh there's no ending_before on the search charge endpoint, you are right.

#

backword pagination in search api.
The only option is to store the next_page as you paginate forward, and then pass the correct page to move backward.

#

This is not ideal, but it looks like it's the only way.