The GET method is not supported for this route. Supported methods: POST. I don't know what is happening, everywhere this route is set up is a post route but it takes it as a get route.
This route is triggered when clicking on a button this is the code
click method on vue
downloadExcel() {
this.$inertia.post('/download/', this.country);
},
route in web.php
Route::post('/download', 'FormController@downloadExcel');
controller method
public function downloadExcel($id)
{
if ($id == null) {
$items = Form::with('country')->get();
dd(json_encode($items));
} else {
$items = Form::where('country_id', $id)->with('country')->orderByDesc('created_at')->get();
dd(json_encode($items));
}
}
I've tried doing composer dumpautoload a couple times and even invalidate cashes / restart also a couple times but this stays as a get request.
How can I fix it?
This is the solution
downloadExcel() {
this.$inertia.post('/download',
{country: this.country}
);
}
Route::post('/download', 'FormController@downloadExcel');
public function downloadExcel(Request $request)
{
if ($request->country == null) {
$items = Form::with('country')->get();
dd(json_encode($items));
} else {
$items = Form::where('country_id', $request->country)->with('country')->orderByDesc('created_at')->get();
dd(json_encode($items));
}
}
Please sign in or create an account to participate in this conversation.