0

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

2
  • 1
    Please post properly formatted code. Currently it is very poorly formatted and have syntax issues. Commented Jan 21, 2023 at 13:50
  • Maybe you should post the error-response that your receive. Commented Jan 21, 2023 at 19:55

1 Answer 1

0

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 boolean true. If you want an HTTP response, don't use the RxJS you've added in the pipe() operator. Handle errors and any other logic in your subscription instead.

Sign up to request clarification or add additional context in comments.

2 Comments

Yes, but err is string not object
Then there's something wrong with your API.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.