【发布时间】:2019-06-20 15:18:45
【问题描述】:
Angular 非常快地取消 http 请求,我想拦截那些取消的请求。 是否可以在拦截器中捕获已取消的请求? 下面是我的拦截器代码片段,我想在其中捕获已取消的请求。
intercept(req: HttpRequest<any>, next: HttpHandler):
Observable<HttpEvent<any>> {
this.onStartRequest();
// Pass the cloned request instead of the original request to the next handle
return next.handle(req).do(
(event: HttpEvent<any>) => {
if (event instanceof HttpResponse) {
// do something
}
},
(err: any) => {
if (err instanceof HttpErrorResponse) {
// do something
}
}
);
}
【问题讨论】:
-
请解释一下在这种情况下“已取消的请求”是什么意思。
标签: angular http angular-http-interceptors