Easy Pagination with Vapor 4

Sis Ccr
Oct 8, 2021
pagination

Pagination in Vapor was very easy as vapor provides the paginate(for: request) function.

we call call this from client side as:

http://{{baseurl}}/rooms?type=house&lowerPrice=0&upperPrice=10000&page=2&per=2

this will return the json with metadata describing the pages attributes.

{
"data": {
"items": [
{
...
"preference": "family",
"phone": "9849192759",
"lat": 27.717199999999998,
...
}
],
"metadata": {
"per": 2,
"total": 4,
"page": 2
}
}
}

This was easier than I thought.

--

--