0
코드에서 나는 http 요청을 가로 채려고합니다. http 연결을 설정할 수있을 때마다 인터셉터가 작동하지만, net::ERR_CONNECTION_REFUSED
을 얻은 경우 event
변수는 HttpResponse
의 인스턴스가 아니므로 이러한 종류의 오류는 처리 할 수 없습니다. 여기 내 코드는 다음과 같습니다각도 4 - 인터셉터 핸들 net :: ERR_CONNECTION_REFUSED
net::ERR_CONNECTION_REFUSED
같은 인터셉터 오류를 감지 할 수있는 방법
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
this.changeStatus(false);
this.requests_count++;
const my_req = req.clone({
url: API_PATH + req.url
});
return next
.handle(my_req)
.do(event => {
if (event instanceof HttpResponse) {
this.requests_count--;
if (!this.requests_count)
this.changeStatus(true);
}
});
}
?