I have two components that depend on a third component function to receive some JSON data. The function that them both use is this:
getAllPosting(before, after) {
return new Promise((resolve, reject) => {
console.log("url", environment.apiLogin + this.apiBase + localStorage.getItem('idEmpresa') + '/' + before + '/' + after)
this.http.get(environment.apiLogin + this.apiBase + localStorage.getItem('idEmpresa') + '/' + before + '/' + after, {headers: {Authorization: this.oauthService.authorizationHeader()}})
.subscribe((result: any) => {
console.log("provider result", result)
resolve(result);
},
(error) => {
reject(error);
});
});
}
On the first component, the console.log("provider result", result) statement shows this result:

However, on the second component, the highlighted console.log shows this result:

It's does not seem to be a back-end problem since on the db all the data and the queries return the correct result. There are thousands of users but none of them have this problem, except for this current user.
This error is resulting to no data being show on the table, like:

I've tried requesting the data on different clients but none of them have this problem. It is exclusive of this one user.
Also, when trying to console.log the array using a forEach iteration, the correct information is showing. However, when trying to console.log the whole object, the main fields that we use for the table keep showing as Nan.
result.forEach(element => {
console.log("foreeach",element.amountPaid)
});

If the data that comes back from the http.get call is truly correct, there is a chance that the object that is returned from the service is later manipulated by the code that is triggered after resolve(result) is called.
So when you attempt to view the result object in the console, what you will see is what the result of that manipulation is, not what the object was during the console.log call. This would explain why you are seeing correct values during the foreach prints, as the console is printing number literals - not objects, however they are likely then changed by the code that gets triggered when the promise is resolved.
Hence, I would recommend checking the code that uses the getAllPosting result.