Getting Typescript Error For Options Configuration In An Angular 8 App
I'm getting the following error when trying to call a service using rest api and a get call: Argument of type '{ headers: HttpHeaders; responseType: string; }' is not assignable
Solution 1:
You should change your code to
public getTripNameById(tripId: number): Observable<any> {
const httpOptionsText = {
headers: new HttpHeaders({
Accept: "text/plain",
"Content-Type": "text/plain"
}),
responseType: "text" as "json"
};
return this.http.get<any>(
`${this.baseUrl}/Trips/Trip/Name/${tripId}`,
httpOptionsText
);
}
Post a Comment for "Getting Typescript Error For Options Configuration In An Angular 8 App"