app.put("/update/:id", async (req, res) => {
var pastEmail = "";
var pastName = "";
await connection.query(
`select * from users where ID=${req.params.id}`,
(err, result1) => {
err && console.log(err);
pastEmail = result1[0].email;
pastName = result1[0].name;
console.log(pastEmail);
console.log(result1[0]);
}
);
console.log("past mail", pastEmail);
let name = req.body.name ? req.body.name : pastName;
var email = req.body.email ? req.body.email : pastEmail;
need the pastEmail data in email, I tried await but it did not worked. This is how the output looks like...
past mail mail@email.in RowDataPacket { ID: 5, name: 'Ghungru set', email: 'mail@email.in', password: '1234' }
could you Please help me to find my mistake!