Reputation:
I want to fetch the Authenticated User's data in API controller. How to do that?
Here is my API\CompanyController
public function selected_company(){
return Auth::user()->id;
}
The error I got through HTTP request...
Upvotes: 1
Views: 745
Reputation: 7992
To convey the comment in a comprehensible manner,
Either your controller should have a middleware, like
public function __construct()
{
$this->middleware('auth:api');
}
Or your route to the api should be passed through the middleware
Route::get('your-api-endpoint')->middleware('auth:api');
Upvotes: 1