Let's setup the Catalyst function next.
app.post("/capture_pan", (req, res) => {
let catalystApp = catalyst.initialize(req, {type: catalyst.type.applogic});
const requestBody = req.body;
console.log(req.body)
//Get table meta object without details.
let table = catalystApp.datastore().table('PANID');
//Use Table Meta Object to insert the row which returns a promise
let insertPromise = table.insertRow({
PanID: requestBody.pancard_id,
Salary: requestBody.salary,
PhoneNumber:requestBody.contact_number,
Occ_type:requestBody.occupation
});
insertPromise
.then((row) => {
console.log("\nInserted Row : " + JSON.stringify(row));
res.status(200).json(row);
})
.catch((err) => {
console.log(err);
res.status(500).send(err);
});
});