Closures
For Closures, the name of the route becomes the name of the calling function, which can be imported from "Closures"
tip
dashboard.data
will be used as dashboardData
Backend Closure in web.php
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()
});