import { Injectable } from '@angular/core'; import { HttpClient, HttpErrorResponse } from '@angular/common/http'; import { IEmployee } from './employee'; //import { Observable } from 'rxjs'; import { throwError } from 'rxjs'; import { catchError, retry } from 'rxjs/operators'; @Injectable({ providedIn: 'root' }) export class EmployeeService { private _url: string = "/assets/data/employees.json" constructor(private http: HttpClient) { } getEmployees(): Observable{ return this.http.get(this._url) .pipe( catchError(this.errorHandler) ); } errorHandler(error: HttpErrorResponse){ return throwError(error); } }