Currently, I am attempting to capture errors in the HTTP get request within my service file.
Below is the code snippet:
import { Injectable } from '@angular/core';
import { PortfolioEpicModel, PortfolioUpdateStatus } from '../models/portfolio-epic.model';
import { HttpClient, HttpErrorResponse, HttpParams} from '@angular/common/http'
import { config, Observable } from 'rxjs';
import { retry, catchError } from 'rxjs/operators';
refreshPortfolioEpicsList(id:number):Observable<PortfolioEpicModel[]>{
this.baseUrl=this.conf.getSettings("apiUrl");
return this.http.get<PortfolioEpicModel[]>(this.baseUrl+ "/api/pepics/"+ id.toString())
.pipe(catchError(this.errorHandler));
}
errorHandler(error:HttpErrorResponse){
console.info(error.message);
}
However, when trying to use the catchError
method, the following error is displayed:
Argument of type '(error: HttpErrorResponse) => void' is not assignable to parameter of type '(err: any, caught: Observable<PortfolioEpicModel[]>) => ObservableInput'. Type 'void' is not assignable to type 'ObservableInput'.ts(2345)
I am unsure how to resolve this issue.
My current environment is Angular 11.