Hi,
I’m trying to build a vue-plugin for the frontend, where I want to paginate results in an API-Call to /api/pages/:id/children/search?select=content,files
.
I definatly don’t want to paginate all results in the frontend (fetch all and paginate on client-side), but in the api-call itself. That should be possible out of the box, right (<code>GET|POST</code> /api/pages/:id/children/search | Kirby CMS)?
I already found the forum-thread for the filterBy
-option, which isn’t really intuitive and documented like that, so I assume the paginate-solution is kinda complicated as well?!
I was hoping that just using the limit
and offset
-params would do the trick (as they at least limit and offset the results), but the response-pagination-object returns nonsense data.
For example:
- I don’t use limit and offset in the POST-Body:
{ "page": 1, "total": 4, "offset": 0, "limit": 20 }
- I say
limit: 1, offset: 0
, I get in the response{ "page": 1, "total": 1, "offset": 0, "limit": 1 }
But in order to build the pagination in the Frontend, I need a correct total
info. The available paginate
-Array I got no clue how to use.
I’m using Kirby 3.8.0-rc.1
Here’s the codebase:
const postParams: PostParams = {
search: selectedFilters?.searchText || '',
filterBy: [],
limit: 1,
page: 1,
};
const response = await fetch('/api/pages/foo/children/search?select=content,files', {
method: 'POST',
body: JSON.stringify(postParams),
headers: {
'X-CSRF': window.csrf,
'X-Language': 'en_US',
},
});