angular设置网络请求超时时间
angular5之后使用pipe
this.http.get('url')
.pipe(
timeout(1000),
catchError(e => {
return of(null);
})
).toPromise().then(
res => {
//成功
}).catch(e => {
//报错
);
angular5之后使用pipe
this.http.get('url')
.pipe(
timeout(1000),
catchError(e => {
return of(null);
})
).toPromise().then(
res => {
//成功
}).catch(e => {
//报错
);