将allvalues和formData中的值放到一个数组中



我正试图将allvalues和formData中的值传递到单个数组中,并通过react axios传递它

constructor(props) {
super(props);

this.state = {
allValues: {
name: "",
class: "",
school: "",

},
files: {
car: null,
bus: null,
scooter: null,
},
};
let formData = new FormData();
formData.append("antenatalChart", this.state.files.car);
axios.post("url",
formData, //appand formdata and allValues
{
headers: {
Authorization: `token ` + localStorage.getItem("token"),
"Content-type": "multipart/form-data",
},
}
)
.then((res) => {
console.log(`Success` + res.data);
})

我试图传递值在allvalues和formData到一个数组,并通过反应传递它

请看这里。这将帮助您理解如何处理表单中的多个输入。

最新更新