How does Axios send POST requests for FormData?

< H2 > when we test, we can use the fetch call to execute normally, but there is a problem when the front end uses Axios for docking. < / H2 >

fetch

@PostMapping(GlobalConstant.DIRECT_PATH + "/user/sendCode")
public JsonResult sendCode(User user) {
    return null;
}

or is there a better way to request? Thank you

Apr.20,2021

var formData = new FormData(form)
formData.append('phone', '12345678910');

axios({
        method: 'post',
        url: '',
        data: formData
    })
    .then(res => console.log(res.data))


var params = new FormData();
params.append('phone', '12345678910');

axios.post(ctx + '/direct/user/sendCode', params,{
    headers:{
       "Content-Type": "multipart/form-data" 
    }
})
  .then(res => console.log(res.data))

there are two ways to solve this problem. You can refer to my article, both of which can solve your problem
axios sending request


I have the same problem. Do you have a solution?

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b38051-2c0d1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b38051-2c0d1.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?