import { Injectable } from '@angular/core' ; import { HttpClient } from '@angular/common/http' ; import { Observable } from 'rxjs/Observable' ; import { catchError } from 'rxjs/operators' ; import 'rxjs/add/observable/throw' ; import { Topping } from '../models/topping.model' ; @ Injectable ( ) export class ToppingsService { constructor ( private http ) { } getToppings ( ) { return this . http . get < Topping [ ] > ( `/api/toppings` ) . pipe ( catchError ( ( error ) => Observable . throw ( error . json ( ) ) ) ) ; } }