RXJS5版本
在RXJS5上我们是这样写请求的
import 'rxjs/add/observable/of';
import 'rxjs/add/observable/throw';
import 'rxjs/add/observable/map';
import 'rxjs/add/observable/mergemap';
this.http
.get<{id: number; userId: number; title: string; body: string}[]>(
'http://...........'
)
.map(data => {
return ......;
})
.catch(error => {
.....
})
.subscrible(...)
RXJS6对应修改为:
import {HttpClient} from '@angular/common/http';
import {Observable, of, throeError} from 'rxjs';
import {map, catchError} from 'rxjs';
this.http
.get<{id: number; userId: number; title: string; body: string}[]>(
'http://...........'
)
.pipe(
map(data => {
return ......;
}),
catchError(error => {
return throwError('.....');
})
)
.subscrible(...)