我创建了简单的 Angular 7 表单和后端 express 节点应用程序现在我想将数据存储到数据库(Dynamodb)中,所以我如何将它与我的应用程序连接起来,该应用程序从前端获取输入并将数据存储到数据库中
app.post('/business/add', (req, res) => {
var table = "business";
var person_name = req.body.person_name;
var business_name = req.body.business_name;
var business_gst_number = req.body.business_gst_number;
var params = {
Item: {
"person_name": {
S: person_name
},
"business_name": {
S: business_name
},
"business_gst_number": {
N: business_gst_number
}
},
ReturnConsumedCapacity: "TOTAL",
TableName: "business"
};
console.log("Adding a new item...");
doClient.putitem(params, function(err, data) {
if (err) {
console.error("Unable to add item. Error JSON:", JSON.stringify(err, null, 2));
} else {
console.log("Added item:", JSON.stringify(data, null, 2));
}
});
// console.log(req.body);
// res.json({});
});`