Skip to content

Commit d4ac969

Browse files
committed
Revert "docs: refactor style guide example 03-06 (angular#24996)"
This reverts commit 65e18dc.
1 parent c205516 commit d4ac969

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

aio/content/examples/styleguide/src/03-06/app/heroes/shared/hero.service.avoid.ts

+6-6
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/* avoid */
44

55
import { ExceptionService, SpinnerService, ToastService } from '../../core';
6-
import { HttpClient } from '@angular/common/http';
6+
import { Http } from '@angular/http';
77
import { Injectable } from '@angular/core';
88
import { map } from 'rxjs/operators';
99
import { Hero } from './hero.model';
@@ -16,17 +16,17 @@ export class HeroService {
1616
private exceptionService: ExceptionService,
1717
private spinnerService: SpinnerService,
1818
private toastService: ToastService,
19-
private http: HttpClient
19+
private http: Http
2020
) { }
2121

2222
getHero(id: number) {
23-
return this.http.get<Hero>(`api/heroes/${id}`).pipe(
24-
map(response => response.data as Hero));
23+
return this.http.get(`api/heroes/${id}`).pipe(
24+
map(response => response.json().data as Hero));
2525
}
2626

2727
getHeroes() {
28-
return this.http.get<Hero[]>(`api/heroes`).pipe(
29-
map(response => response.data as Hero[]));
28+
return this.http.get(`api/heroes`).pipe(
29+
map(response => response.json().data as Hero[]));
3030
}
3131

3232
}

aio/content/examples/styleguide/src/03-06/app/heroes/shared/hero.service.ts

+8-9
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,11 @@
11
// #docregion
22
// #docregion example
3-
import { HttpClient } from '@angular/common/http';
43
import { Injectable } from '@angular/core';
5-
import { map } from 'rxjs/operators';
4+
import { Http } from '@angular/http';
5+
import { map } from 'rxjs/operators';
66

7-
import { ExceptionService, SpinnerService, ToastService } from '../../core';
87
import { Hero } from './hero.model';
9-
8+
import { ExceptionService, SpinnerService, ToastService } from '../../core';
109
// #enddocregion example
1110

1211
@Injectable()
@@ -17,17 +16,17 @@ export class HeroService {
1716
private exceptionService: ExceptionService,
1817
private spinnerService: SpinnerService,
1918
private toastService: ToastService,
20-
private http: HttpClient
19+
private http: Http
2120
) { }
2221

2322
getHero(id: number) {
24-
return this.http.get<Hero>(`api/heroes/${id}`).pipe(
25-
map(response => response as Hero));
23+
return this.http.get(`api/heroes/${id}`).pipe(
24+
map(response => response.json() as Hero));
2625
}
2726

2827
getHeroes() {
29-
return this.http.get<Hero[]>(`api/heroes`).pipe(
30-
map(response => response as Hero[]));
28+
return this.http.get(`api/heroes`).pipe(
29+
map(response => response.json() as Hero[]));
3130
}
3231

3332
}

0 commit comments

Comments
 (0)