I create simple angular 7 form and backend express node app now I want to store data into Database(Dynamodb) so how I connect it with my application that takes inputs from frontend and store data into db
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({});
});`
Use Angular http service to make request to the server (localhost/ip/domain). Angular Http
On server side configure aws-sdk.Configure aws-sdk
Once aws_access_key_id and aws_secret_access_key are configured you can make connection to DynamoDb
Refer this official Dynamo db docs for nodejs for CRUD ops. DynamoDb Nodejs