I am consuming Dot net Web API which generates HighChart structure it has X and Y axis of type double.
The X-axis stores the DateTime EPOCH format for example (1554120000000), i am getting the correct format when i call the endpoint from postman
But when i am consuming the same endpoint from my angular application, The number is getting converted to exponential (-1.7976931348623157e+308)
I have referred to the question! on Stackoverflow and used the method from the answer but it is not giving the correct number
var epochTime = 1554120000000;
var exponentialNumber = -1.7976931348623157e+308;
function toFixed(x) {
if (Math.abs(x) < 1.0) {
var e = parseInt(x.toString().split('e-')[1]);
if (e) {
x *= Math.pow(10,e-1);
x = '0.' + (new Array(e)).join('0') + x.toString().substring(2);
}
} else {
var e = parseInt(x.toString().split('+')[1]);
if (e > 20) {
e -= 20;
x /= Math.pow(10,e);
x += (new Array(e+1)).join('0');
}
}
return x;
}
console.log("expected:" + epochTime)
console.log("result: " + toFixed(exponentialNumber));
How to avoid this converison, if not they how to parse the number correctly?