Alright, we've prepared our model and database for handling users within our application. Now, we can create a new service that we are using in our container components to obtain the currently logged in user. Let's create a user service using the Angular CLI:
ng generate service --spec false user/user
Let's open the stub service generated on the src/app/user/user.service.ts path and replace its content with the following code:
import {Injectable} from '@angular/core';import {HttpClient} from '@angular/common/http';import {User} from '../model';@Injectable()export class UserService { constructor(private http: HttpClient) { } getCurrentUser() { return this.http.get<User>('/api/users/1'); }}
We're keeping things simple here. The ...