laravel框架, 前台使用ajax提交表單資料,
當type: 'get'時,後台可以透過$request->user()->id 取得到使用者id,
但是
當type: 'post'時,後台透過$request->user()->id 報錯500.
routes.php
<code>Route::group(['middleware' => 'web'], function () { Route::auth(); //这个url使用post报错 Route::get('/index/folder', "IndexController@folder"); });</code>
controllder
<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>
請問這是怎麼回事,如何解決?
laravel框架, 前台使用ajax提交表單資料,
當type: 'get'時,後台可以透過$request->user()->id 取得到使用者id,
但是
當type: 'post'時,後台透過$request->user()->id 報錯500.
routes.php
<code>Route::group(['middleware' => 'web'], function () { Route::auth(); //这个url使用post报错 Route::get('/index/folder', "IndexController@folder"); });</code>
controllder
<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>
請問這是怎麼回事,如何解決?