It's time to change our task service and make use of the Angular HTTP client to obtain the task data from our database. Let's open up the src/app/tasks/task.service.ts file and change the file content to the following:
import {Injectable} from '@angular/core';import {HttpClient} from '@angular/common/http';import {BehaviorSubject} from 'rxjs';import {Task} from '../model';@Injectable()export class TaskService { private tasks = new BehaviorSubject<Task[]>([]); constructor(private http: HttpClient) { this.loadTasks(); } private loadTasks() { this.http.get<Task[]>('/api/tasks') .subscribe((tasks) => this.tasks.next(tasks)); } getTasks() { return this.tasks.asObservable(); } addTask(task: Task) { return this.http ...