import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { Observable , throwError } from 'rxjs' ; import { catchError , map } from 'rxjs/operators' ; import { User } from './user' ; @ Injectable ( ) export class UsersService { constructor ( private http ) { } public getUsers ( ) { const uri = '/api/users' ; return this . http . get ( uri ) . pipe ( map ( ( response ) => response . _embedded [ 'users' ] ) , catchError ( this . handleError ) ) ; } private handleError ( error ) { const errMsg = 'UsersService: cannot get users from http server.' ; console . error ( errMsg ) ; return throwError ( errMsg ) ; } }