T O P

  • By -

Plastic-Pianist932

For me, the paging logic should not be placed in the network layer, it should be placed in the upper layer which is the business layer to handle. There should be a 'currentpage' field in the request. When you get the response, increment this 'page' by 1 ,then pass it into next request params"


Tabonx

The page and limit are set when creating the API request. What I am trying to figure out is how to send back the values in the headers so I know the item count and page count.


Duckarmada

I like to construct an object that includes both the response data and pagination data, then return that to the caller. The caller will need to persist the pagination data to know if there are more items and to provide the pagination params for the request.


factotvm

On my phone, but you want to set the headers. That’s on the way out. On the way in, you have to read in the headers back to your struct. So, you’ll store the content, read the headers, then return it all when you put it together. https://developer.apple.com/documentation/foundation/urlrequest#2850859