问题
Here is my request:
axios.get(url)
.then(res => {
console.log(res.data)
})
The output is { value: 156144277082605255 }
But should be { value: 156144277082605250 }
How to deal with Big Integers in this case? I tried to use json-bigint But since I am getting response.data from axios as object - it doesn't help.
回答1:
My colleague answered the question:
I had to transform my response.data into string. (you may wonder - why the useless function - just to redefine default behavior, which parses string into object with JSON.parse - in here we skip this step)
axios.get(url, { transformResponse: [data => data] });
and then parse with json-bigint
JSONBigInt.parse(res.data);
来源:https://stackoverflow.com/questions/43787712/axios-how-to-deal-with-big-integers