laravel framework, the frontend uses ajax to submit form data,
when type: 'get', the backend can get the user id through $request->user()->id,
but
when type: 'post ', the background reports error 500 through $request->user()->id.
routes.php
<code>Route::group(['middleware' => 'web'], function () { Route::auth(); //这个url使用post报错 Route::get('/index/folder', "IndexController@folder"); });</code>
controller
<code> public function folder(Request $request, FoldersRepository $FoldersRep) { return response($request->user()->id); }</code>
js
<code> $.ajax({ type: 'get', url: "/index/folder", data: formData, success: function (data) { console.log(data); debugger</code>
What is going on and how to solve it?
laravel framework, the frontend uses ajax to submit form data,
when type: 'get', the backend can get the user id through $request->user()->id,
but
when type: 'post ', the background reports error 500 through $request->user()->id.
routes.php
<code>Route::group(['middleware' => 'web'], function () { Route::auth(); //这个url使用post报错 Route::get('/index/folder', "IndexController@folder"); });</code>
controller
<code> public function folder(Request $request, FoldersRepository $FoldersRep) { return response($request->user()->id); }</code>
js
<code> $.ajax({ type: 'get', url: "/index/folder", data: formData, success: function (data) { console.log(data); debugger</code>
What is going on and how to solve it?