While sending a post request from my angular application to a web api, I am encountering an issue. The response from the api is supposed to be either a 200 status or a 404 status without any data being returned. An example of some headers for the 200 response are
{ "content-length": "0", "content-type": null }
. Here is the block of Typescript code responsible for making the post request:
return this.http.post(url, "", { params: params }).catch(err => {
console.log(err);
throw "";
});
The problem arises when I receive an error even for the 200 response with the message: Unexpected end of JSON input
.
How can I properly handle and evaluate the response code in order to accurately determine success (return true) or failure (return false)?