I've implemented a post
method using Angular's HttpClient
.
While attempting to subscribe to the response for additional tasks, I encountered the following error:
Error: Uncaught (in promise): HttpErrorResponse: {"headers":{"normalizedNames":{},"lazyUpdate":null},"status":200,"statusText":"OK","url":"XXXXXXX","ok":false,"name":"HttpErrorResponse","message":"Http failure during parsing for XXXXXXXX","error":{"error":{},"text":"OK"}}
I read that this could be due to the response not being valid JSON. When testing in Postman, I received an OK response but not in JSON format.
My question is, how can I address this issue? Is there a way to convert the response into JSON?
This is what my method currently looks like:
submitInfo() {
this.http.post(url, data).toPromise()
.then(
(response: Response) => {
console.log(response);
}
));
}