My objective is to automatically redirect users to the login page whenever a login attempt fails. I have implemented an interceptor to manage Http responses:
export class HttpInterceptor implements HttpInterceptor {
intercept(request: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(request).do((event: HttpEvent<any>) => {}, (err: any) => {
if (err instanceof HttpErrorResponse) {
console.log("Intercepted HTTP error")
}
});
}
}
However, I encountered an error stating "property do does not exist on type observable>". I'm also unsure how to redirect users back to the login page from the interceptor. Can anyone provide guidance on how to resolve this issue? Your assistance is greatly appreciated, thank you!