I’d like to use the kirby api endpoint /api/pages/:id/files from a controller.
I’m logged in as an admin and have the following in my controller. However the response I get still says: Unauthenticated. What am I missing here?
I would like to do an ajax request from the frontend to get all files under the current page.
I know I could go with the option of creating a template.json.php template and get the data from there but I thought why not using the API if I’m logged into the frontend anyway. Seems much cleaner to me.
The example above with the controller was just for testing purposes to see how the data will be returned. I’d use javascript on the frontend to do the ajax call.