import { Observable } from 'rxjs/Observable'; import 'rxjs/add/operator/map'; import 'rxjs/add/operator/catch'; import 'rxjs/add/observable/throw'; updatePassenger(passenger: Passenger): Observable<Passenger> { let headers = new Headers({ 'Content-Type': 'application/json' }); let options = new RequestOptions({ headers: headers }); return this.http .put(`${PASSENGER_API}/${passenger.id}`, passenger, options) .map((response: Response) => response.json()) .catch((error: any) => Observable.throw(error.json())); }