I used RxJS like below:
catchError((error: any) => {
if (error instanceof HttpErrorResponse) {
.......
if (error.status === 401) {
.....
return;
}}
But cacheError((error:any) usage gives below error:
Argument of type '(error: any) => Observable | undefined' is not assignable to parameter of type '(err: any, caught: Observable<HttpEvent>) => ObservableInput'. Type 'Observable | undefined' is not assignable to type 'ObservableInput'. Type 'undefined' is not assignable to type 'ObservableInput'
How can I solve it? I am using rxjs 6.6.3 version
CodePudding user response:
According to RxJS docs / learn
Remember to return an observable from the catchError function!
So to get rid of the error, you could return empty observable of()
:
catchError((error: any) => {
if (error instanceof HttpErrorResponse) {
.......
if (error.status === 401) {
.....
return of();
}}