通过laravel中的api发送关系请求

时间:2020-02-12 07:47:09

标签: php laravel api jwt postman

如何通过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',

    ]);
}

1 个答案:

答案 0 :(得分:0)

这意味着令牌无效,如果使用tymon软件包,请检查此中间件('middleware'=>'api')是否适用于此路由以检查令牌验证