【发布时间】:2021-03-18 11:10:38
【问题描述】:
状态就像
state = {
courseTitle: "",
courseImage: "",
duration: "",
overView: "",
syllabus: [
{
title: "",
description: "",
},
],
};
我正在使用 FormData() 提交数据,因为我也有图像
handleSubmit = (e) => {
e.preventDefault();
const fd = new FormData();
fd.append("courseTitle", this.state.courseTitle);
fd.append("courseImage", this.state.courseImage);
fd.append("duration", this.state.duration);
fd.append("overView", this.state.overView);
fd.append("syllabus", this.state.syllabus);
this.props.addCourse(fd);
};
除了教学大纲,一切都很好,因为它在数组中,FormData 发送一个教学大纲的值,
syllabus:[object object]
请任何人帮助我如何发送具有上述状态格式的数组数据,我正在为后端 nodejs、express 和 mongodb 使用 react 和 redux
【问题讨论】:
标签: javascript node.js reactjs mongodb