So I have a little static html and vanilla JS app that will eventually be turned into a iOs and Android apps. It fetches data from a headless instance of Kirby but needs to hit a route to get back recommended prodcuts based on tags generated on the static site.
It basically shows a range of books and based on the range of books chosen by the user, it then returns a list of recceomended titles.
Im not really sure how to format the list to send to the route. Right now i have as the result:
const params = new URLSearchParams({
genres: comichoices.toString(), // this comes from data in local storage
});
Basically I need to send that through to a Kirby route which then returns a list of matching titles, by filtering the entire catalagoue of titles by those tags, then returning the result back to the static app as JSON.
Not sure if that’s the best way to do it but some thoughts:
You could use a custom route, but you could also use a content representation and use a controller. Depends on your setup what feels more fitting to the rest of the site.
In a route you can use $this->requestQuery('genres') to get the query value, in a controller $kirby->request()->get('genres')
Split by , to get an array of genres and then do your search/filter logic on your pages
Depending on how large the list of pages is/how performance heavy the searching/filtering, you might want to cache your response with the genres query as key, so that repeated requests for the same genres can be served directly from your custom cache.