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);
});
var bodyFormData = new FormData();
bodyFormData.append('userName', 'Fred');
bodyFormData.append('image', imageFile);
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);
});
//assuming instance is your axios instance.
instance.get("/test",{params:{key:value, key1:value1}}).then((data)=>{}).catch((error)=>{})
//this will send a GET request to /test?key=value&key1=value1