Angular/Laravel – getting ‘No query results for model [AppModelsUser]’ error

  angular, laravel

I’m working with Laravel and Angular. I want to display the authenticated user’s data. I’m getting datas from Laravel with JSON and I’m using this code for the user datas.

  const headers = new HttpHeaders({
      Authorization: `Bearer ${localStorage.getItem('token')}`
    this.http.get('', {headers}).subscribe(
      result => (this.user = result,


It’s working but after a certain time this code does not work and I’m getting the error in console.

No query results for model [AppModelsUser] 404 (Not Found)

What am I missing?


public function user() {
    $user = User::where('id',Auth::id())->firstorfail();
    return response()->json($user);


Route::get('/user', [UserController::class, 'user']);

Source: Laravel

Leave a Reply