【发布时间】:2021-02-04 04:52:40
【问题描述】:
我将 axios.post() 中的数据发送到 Node.js 中的函数。该函数不接受数据的所有参数。 我的错误是什么??
这是 React 中的代码:
axois.post('http://localhost:9000/question/create', **question**)
.then((res) => {
console.log('res.data -> ', res.data); // The res.data sends all the data (see it in the console)
}).catch((error) => {
console.log('error -> ', error);
});
这是 Node.js 中的代码:
console.log('req -> ', req.body); // The req.body didn't get all the parameters of the data that came to it.
dataQuestion.create(**req.body**, (error, data) => {
if (error) {
return next(error)
} else {
console.log(data)
res.json(data)
}
});
}); ```
Appreciates any answer ...
Thank you!
【问题讨论】:
标签: node.js reactjs mongodb api axios