但这只需要在请求url与特定url匹配时发生
我的问题是,在如下场景(或习惯用法)中,我们如何检查请求url:
//interceptor code
return next.handle(req).pipe(
catchError((error : HttpErrorResponse) => {
if (error.error instanceof ErrorEvent) {
console.log('Error ');
}
else {
if(error.status.startsWith('5')){
//redirect to page but only when request url matches specific url
}
console.log('Error');
}
})
);
if(event instanceof HttpResponse)
{
const responseUrl = event.url;
if((event.status === 200) && (responseUrl.includes('certailUrl'))){
window.location.reload();
return Observable.create(empty);
}
}