Skip to content

Instantly share code, notes, and snippets.

Last active Jan 13, 2022
What would you like to do?
An example of a public endpoint in cockpit
// Place this file at config/api/public/testing.php
// Replace `mycollection` with the name of one of your collections
// Access it at
try {
$arg = $this->param('myarg')
$items = cockpit('collections')->find('mycollection', ['limit' => 10]);
return ['arg' => $arg, 'items' => $items];
} catch (\Throwable $th) {
return ['error' => $th->getMessage() . "\n" . $th->getTraceAsString()];
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment