Since you tagged your question rxjs6, I'm assuming the upgrade to Angular 6 includes an upgrade to rxjs6. In that case, it's not working because methods on the observable object are now standalone operators that you can apply using pipe(). Also, imports have changed. See the migration guide for more details.
With rxjs6 it should look something like this:
import { Observable, EMPTY, throwError } from 'rxjs';
import { catchError } from 'rxjs/operators';
private authInterceptor(observable: Observable<Response>): Observable<Response> {
return observable.pipe(
catchError( err => {
if (err.status == 401) {
this.router.navigateByUrl('/login');
return EMPTY;
} else {
return throwError(err);
}
})
);
}
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…