axios version 0.16.1
Environment: Mac OS Sierra, Chrome v57
I'm currently using axios.post
and when I nest an object inside of the data object it appears to remove the fields inside of the nested object that have a value of undefined
set.
For instance:
update(locationId, vehicleSaleId, payload) {
//Payload example: {billedFront: undefined}
return axios.post('/api/vehicleSale.update', {
params: {locationId, vehicleSaleId},
payload: payload
})
.then((res) => res.data);
},
Chrome Dev Tools > Network:
{"params":{"locationId":"58e991ddb051fc0f8424552a","vehicleSaleId":"58fa4d2562fd801765652fc3"},"payload":{}}
As you can see payload is just an empty object. It should have a billedFront
field that is set to undefined.
Try setting it to null as a workaround till this is fixed?
@sunnykgupta that works! Thanks for the workaround :)
This isn't a bug the the normal behaviour. JSON.stringify
removes undefined
properties from the resulting object.
Most helpful comment
This isn't a bug the the normal behaviour.
JSON.stringify
removesundefined
properties from the resulting object.