diff --git a/aio/content/examples/styleguide/src/03-06/app/heroes/shared/hero.service.avoid.ts b/aio/content/examples/styleguide/src/03-06/app/heroes/shared/hero.service.avoid.ts index 3b983f5bda..fea2e49d99 100644 --- a/aio/content/examples/styleguide/src/03-06/app/heroes/shared/hero.service.avoid.ts +++ b/aio/content/examples/styleguide/src/03-06/app/heroes/shared/hero.service.avoid.ts @@ -3,9 +3,8 @@ /* avoid */ import { ExceptionService, SpinnerService, ToastService } from '../../core'; -import { Http } from '@angular/http'; +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { map } from 'rxjs/operators'; import { Hero } from './hero.model'; // #enddocregion example @@ -16,18 +15,15 @@ export class HeroService { private exceptionService: ExceptionService, private spinnerService: SpinnerService, private toastService: ToastService, - private http: Http + private http: HttpClient ) { } getHero(id: number) { - return this.http.get(`api/heroes/${id}`).pipe( - map(response => response.json().data as Hero)); + return this.http.get(`api/heroes/${id}`); } getHeroes() { - return this.http.get(`api/heroes`).pipe( - map(response => response.json().data as Hero[])); + return this.http.get(`api/heroes`); } } - diff --git a/aio/content/examples/styleguide/src/03-06/app/heroes/shared/hero.service.ts b/aio/content/examples/styleguide/src/03-06/app/heroes/shared/hero.service.ts index 0a50c11bb4..0dd5931a7a 100644 --- a/aio/content/examples/styleguide/src/03-06/app/heroes/shared/hero.service.ts +++ b/aio/content/examples/styleguide/src/03-06/app/heroes/shared/hero.service.ts @@ -1,11 +1,11 @@ // #docregion // #docregion example +import { HttpClient } from '@angular/common/http'; import { Injectable } from '@angular/core'; -import { Http } from '@angular/http'; -import { map } from 'rxjs/operators'; -import { Hero } from './hero.model'; import { ExceptionService, SpinnerService, ToastService } from '../../core'; +import { Hero } from './hero.model'; + // #enddocregion example @Injectable() @@ -16,18 +16,15 @@ export class HeroService { private exceptionService: ExceptionService, private spinnerService: SpinnerService, private toastService: ToastService, - private http: Http + private http: HttpClient ) { } getHero(id: number) { - return this.http.get(`api/heroes/${id}`).pipe( - map(response => response.json() as Hero)); + return this.http.get(`api/heroes/${id}`); } getHeroes() { - return this.http.get(`api/heroes`).pipe( - map(response => response.json() as Hero[])); + return this.http.get(`api/heroes`); } } -