如何通过api发送这样的请求? 即使在标头中传递了用户的jwt,我仍然收到此错误
ErrorException: Trying to get property 'id' of non-object in file C:\xampp\htdocs\doc\app\Http\Controllers\HistoryApiController.php on line 42
这是存储功能
public function store(Request $request)
{
$history = new History;
$history->history = $request->input('history');
$history->admin_id = auth()->user()->id;
$history->save();
return response()->json([
'message' => 'History added',
]);
}
答案 0 :(得分:0)
这意味着令牌无效,如果使用tymon软件包,请检查此中间件('middleware'=>'api')是否适用于此路由以检查令牌验证