laravel框架 , 前台使用ajax提交表单数据,
当type: 'get'时,后台可以通过$request->user()->id 获取到用户id,
但是
当type: 'post'时,后台通过$request->user()->id 报错500.
routes.phpRoute::group(['middleware' => 'web'], function () {
Route::auth(); //这个url使用post报错
Route::get('/index/folder', "IndexController@folder");
});
controllderpublic function folder(Request $request, FoldersRepository $FoldersRep) { return response($request->user()->id);
}
js$.ajax({ type: 'get', url: "/index/folder", data: formData,
success: function (data) { console.log(data); debugger
请问这是怎么回事,如何解决?