0

当我尝试使用本地主机 reactjs 提交表单时,它显示控制台错误:

“参数中缺少必需的键'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!'
        })
    })
});
4

1 回答 1

2

尝试在参数中将 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
    }
}
于 2021-11-16T20:28:26.780 回答