我已经通过create-react-app使用ReactJS创建了一个简单的待办事项列表应用程序。 我添加的每个待办事项都被推送到名为todos的数组,如下所示。
state = {
inpVal: '',
todos: [],
}
onInputSubmit = (event) => {
event.preventDefault();
//console.log('event fired');
const newTodo = {
value: this.state.inpVal,
completed: false
};
const todos = this.state.todos;
todos.push(newTodo);
this.setState({ todos: todos, inpVal: '' })
}
我想将此todos数组添加到mongoDB。我对此的信息很少。
尝试在Google上进行搜索,但展示了许多不同的方式。我无法把头缠住。
请提出实现此任务的方法/步骤。