app.post("/register", (req, res) => {
let id = req.body.id;
let name = req.body.name;
let email = req.body.email;
cmd = "INSERT INTO emp VALUES(?, ?, ?)";
conn.connect((err) => {
if (err) throw err;
let con = conn.query(cmd, [id, name, email], (err, res) => {
if (err) throw err;
console.log(res);
});
});
});
I have a post endpoint which executes a query. It takes id, name and email from user and stores in database. So, how do I tell user that their data has been saved. In other words, how to send a “Hi your data has been saved” text or even html.
I tried adding app.get inside app.post but it didn’t work.
New contributor
user26503803 is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.