Wednesday, 20 June 2018

Axios response with 64-bit integer

I'm using Axios to request data from an API. The API responds with data, but the data contains a 64-bit integer ID field. JavaScript only supports up to 53-bit integers, so the last digits of the ID are rounded up (or something).Example:I send a request to the APIThe API responds with data containing ID 900,719,925,474,099,199Axios stores this ID as a Number, but because the ID is higher than Number.MAX_SAFE_INTEGER, the last numbers are rounded up resulting in ID 900,719,925,474,099,200and I'm left with an invalid ID.The first solution that came to mind was to simply store the ID as a string instead of a Number, but I don't know how to tell Axios to do that. Is there a way? Do I perhaps have to use another library? Or is there some other solution that I haven't thought of?

Submitted June 20, 2018 at 04:00PM by dr_goodweather

No comments:

Post a Comment