What is the correct way to handle pagination in The Confluence REST API v2

The response contains for the Get Pages and Get Spaces endpoint if you exceed a certain limit, what is the idiomatic way of retrieving all pages/spaces without path manipulation.

  _links: {
    next: '/wiki/api/v2/pages?cursor=....',

I believe that if you wish to retrieve all the pages/space in one shot, you can just loop it through api call until there no more “next path” & store it in a variables.

This method still involve in path manipulation, however you will achieve to retrieve all the data you needed in one shot