You can post axios data by using [FormData()][1] like :
var bodyFormData = new FormData();
And then add the fields to the form you want to send :
bodyFormData.set('product', productName);
If you are uploading images, you may want to use `.append`
bodyFormData.append('file',file);
And then you can use axios post method (You can amend it accordingly)
axios({
method: 'post',
url: 'myurl',
data: bodyFormData,
headers: {'Content-Type': 'multipart/form-data' }
})
.then(function (response) {
//handle success
console.log(response);
})
.catch(function (response) {
//handle error
console.log(response);
});
You can read more [Here][2]
[1]: https://developer.mozilla.org/en-US/docs/Web/API/FormData
[2]: https://github.com/axios/axios/issues/318
You can post axios data by using [FormData()][1] like :
var bodyFormData = new FormData();
And then add the fields to the form you want to send :
bodyFormData.set('userName', 'Fred');
If you are uploading images, you may want to use `.append`
bodyFormData.append('image', imageFile);
And then you can use axios post method (You can amend it accordingly)
axios({
method: 'post',
url: 'myurl',
data: bodyFormData,
headers: {'Content-Type': 'multipart/form-data' }
})
.then(function (response) {
//handle success
console.log(response);
})
.catch(function (response) {
//handle error
console.log(response);
});
You can read more [Here][2]
[1]: https://developer.mozilla.org/en-US/docs/Web/API/FormData
[2]: https://github.com/axios/axios/issues/318