Answers for "axios post formdata"

3

axios post formdata

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);
    });
Posted by: Guest on September-20-2020
0

add formdata to axios request in js

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);
  });
Posted by: Guest on September-05-2021
0

axios react post form data

var body = {
    userName: 'Fred',
    userEmail: '[email protected]'
}

axios({
    method: 'post',
    url: '/addUser',
    data: body
})
.then(function (response) {
    console.log(response);
})
.catch(function (error) {
    console.log(error);
});
Posted by: Guest on November-26-2020
0

How to send form data with Get method in axios?

//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
Posted by: Guest on June-12-2021

Code answers related to "Javascript"

Browse Popular Code Answers by Language