Hi there,
I am currently working on calling an API from the back end using promises in Angular 8 with TypeScript. I am facing an issue where I am unable to receive the error response properly. Whenever I reject the error to get the response/error, I only receive "OK" as a message (msg = "OK"). However, in the console, I can see that there is actually a 500 error along with the response data. You can take a look at the code snippet and the response details in the network tab below:
getAllItem(id: number) {
let promise = new Promise((resolve, reject) => {
this.http.post<any>(environment.apiEndPoint,
{ "Method": "myMethod"},
Helper.getHeader()).toPromise().then((res: any) => {
resolve(res);
},
msg => { reject(msg); });
});
return promise;
}
This is the actual response captured in the network tab:
{"Success": false, "ErrorCode": "SYSTEM909", "Data": {}}
In the network tab, you will see the following information: Status Code: 500
Thank you for your help!