当我尝试使用本地主机reactjs提交表单时,它显示控制台错误:
"params中缺少必需的键"TableName";,代码:"MissingRequiredParameter";,时间:";2021-01-06T06:40:42-102Z"}。
使用AWS放大前端和后端。
后呼叫是:
app.post('/contact', function(req, res) {
console.log(req);
var params = {
Tablename: process.env.STORAGE_FORMTABLE_NAME,
Item: {
id: id(),
name: req.body.name,
email: req.body.email,
phonenumber: req.body.phonenumber,
address: req.body.address,
message: req.body.message
}
}
docClient.put(params, function(err, data) {
if (err) res.json({
err
})
else res.json({
success: 'Contact created successfully!'
})
})
});
尝试将参数中的Tablename更改为Tablename(大写N(,如下所示:
var params = {
TableName: process.env.STORAGE_FORMTABLE_NAME,
Item: {
id: id(),
name: req.body.name,
email: req.body.email,
phonenumber: req.body.phonenumber,
address: req.body.address,
message: req.body.message
}
}