I have an issue because err is returning a string instead of a HttpResponse. I am not sure why, the server returns the content type as "application/json".
Version of Angular is 13.
return this.http.delete(
"http://Localhost:8080/delete",
{ headers: { 'Content-Type': 'application/json' } }
).pipe(
catchError((err, caught) => {
return of(false);
}),
map(() => {
return true;
})
)
I am not sure why doesn’t work
You use RxJS first to catch any errors, throw away the actual error response, and return the boolean
false. Then, if the request is successful, you are using RxJS to map that successful response, throw away the actual response, and return the booleantrue. If you want an HTTP response, don't use the RxJS you've added in thepipe()operator. Handle errors and any other logic in your subscription instead.