By default, when a JavaScript object contains a Date object, Axios serializes it into UTC. This means that the time transmitted is converted using the time zone. This doesn't work for my use case. I need to send the time without the time zone conversion to UTC.
I implemented a custom serializer based on #1548, but it has no effect. I have verified that the config is being modified, but when I look at the request payload, the dates are still using UTC (2022-02-03T04:59:00.000Z).
Note: My logic is more complicated, I am using toLocalString() in the code below to simplify the example.
const a = axios.create()
a.interceptors.request.use((config) => {
config.paramsSerializer = (params) =>
qs.stringify(params, {
serializeDate: (date: Date) => date.toLocaleString(),
})
return config
})
Anyone understand why I can't override the default behavior and use my own date formatting?
Environment Axios Version 0.21.1