The difference between the two forms of FormData data requested by http

send a post request with axios and send data using FormData in the format

jQuery

what"s the difference between the two? Because the first response is true, but it doesn"t seem to have been deleted yet!

export const delHandBook= params => {
    return axios.post(`${base}/fileManage/deleteHandBook`, params, {headers: {"Content-Type": "application/x-www-form-urlencoded;charset=UTF-8"}}).then(res => res.data);
};
Mar.07,2021

what's the difference between payload and formData?


one is passed as is, and the other is passed after url encoding, corresponding to multipart/form-data and urlencode


, respectively.

you send the value of formData directly in axios, which is what you look like in figure 1. The failure to delete is due to the fact that your backend did not properly handle the data you submitted in the past.

if you want to use formData and the data passed is figure 2, you can use URLSearchParams to wrap it (if any, the file will be dropped by Filter)

   

Menu