File tree 2 files changed +14
-15
lines changed
aio/content/examples/styleguide/src/03-06/app/heroes/shared
2 files changed +14
-15
lines changed Original file line number Diff line number Diff line change 3
3
/* avoid */
4
4
5
5
import { ExceptionService , SpinnerService , ToastService } from '../../core' ;
6
- import { HttpClient } from '@angular/common /http' ;
6
+ import { Http } from '@angular/http' ;
7
7
import { Injectable } from '@angular/core' ;
8
8
import { map } from 'rxjs/operators' ;
9
9
import { Hero } from './hero.model' ;
@@ -16,17 +16,17 @@ export class HeroService {
16
16
private exceptionService : ExceptionService ,
17
17
private spinnerService : SpinnerService ,
18
18
private toastService : ToastService ,
19
- private http : HttpClient
19
+ private http : Http
20
20
) { }
21
21
22
22
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 ) ) ;
25
25
}
26
26
27
27
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 [ ] ) ) ;
30
30
}
31
31
32
32
}
Original file line number Diff line number Diff line change 1
1
// #docregion
2
2
// #docregion example
3
- import { HttpClient } from '@angular/common/http' ;
4
3
import { Injectable } from '@angular/core' ;
5
- import { map } from 'rxjs/operators' ;
4
+ import { Http } from '@angular/http' ;
5
+ import { map } from 'rxjs/operators' ;
6
6
7
- import { ExceptionService , SpinnerService , ToastService } from '../../core' ;
8
7
import { Hero } from './hero.model' ;
9
-
8
+ import { ExceptionService , SpinnerService , ToastService } from '../../core' ;
10
9
// #enddocregion example
11
10
12
11
@Injectable ( )
@@ -17,17 +16,17 @@ export class HeroService {
17
16
private exceptionService : ExceptionService ,
18
17
private spinnerService : SpinnerService ,
19
18
private toastService : ToastService ,
20
- private http : HttpClient
19
+ private http : Http
21
20
) { }
22
21
23
22
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 ) ) ;
26
25
}
27
26
28
27
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 [ ] ) ) ;
31
30
}
32
31
33
32
}
You can’t perform that action at this time.
0 commit comments