从 angular 5 到 6(使用 angular 6 和 rxjs 6),在我的 linter 中出现以下两个错误。任何人有任何想法,请,谢谢。
[ts] 'catchError' is declared but its value is never read.
[ts] Property 'catchError' does not exist on type 'Observable<HttpEvent<any>>'.
import { Injectable, Injector } from '@angular/core';
import { HttpEvent, HttpInterceptor, HttpHandler, HttpRequest } from '@angular/common/http';
import { catchError } from 'rxjs/operators';
import { Observable } from 'rxjs';
@Injectable()
export class HttpInterceptorService implements HttpInterceptor {
constructor() { }
intercept(req: HttpRequest<any>, next: HttpHandler): Observable<HttpEvent<any>> {
return next.handle(authReq)
.catchError((error, caught) => {
console.log('Error Occurred');
console.log(error);
return Observable.throw(error);
}) as any;
}
}