Axios: Send null value as param in request

F.M.F. picture F.M.F. · Jul 18, 2017 · Viewed 7.3k times · Source

Is there a possibility to pass a parameter with the value of null to axios? It seems that null values are just ignored...

Answer

Ken Tan picture Ken Tan · Nov 26, 2017

An empty string should do the trick.

var data = new FormData();
data.append('location_id', '');
axios.post('/location/update', data)
.then(function(response) {
    console.log(response.data);
})
.catch(function(error) {
    console.log(error);
});