Closures
For Closures, the name of the route becomes the name of the calling function, which can be imported from "Closures"
Backend Controller
Route::get('dashboard-data', function () {
return \App\Models\User::query()->get();
})->name('dashboard.data')->prefix('action');
Frontend
import { dashboardData } from '@actions/Closures';
//...
dashboardData.call({
params: {
q: 'Amber',
},
}).then(async (r) => {
const res = await r.json()
});