I am using passport package for Laravel API Authentication. When I post data I get error:
401 Unauthorized","error":{"error":"Unauthenticated."}.
I use Auth::user()->id;
to get current user id.
How to solve this error?
This code helped me:
auth()->guard('api')->user()
for shortline syntax you can use something like this:
auth('api')->user()