I have an issue with the MySQL route, After executing the MySQL query, the browser waiting/pending for something, though I have used the connection.end() method
I have checked the database, the data was successfully stored, I need to execute second part of the code after the SQL query
route.js
app.post('/data',(req,res)=>{
let sql = 'INSERT INTO `data` (`name`) VALUES (?)'
connection.query(sql,req.body.name,(err,result)=>{
if(err) throw err
console.log ( 'value inserted')
connection.end()
})
})
I want to execute the following code after the connection close
var text = document.querySelector("input").value;
var node = document.createElement("p");
if (text!=""){
var textnode=document.createTextNode(text);
node.appendChild(textnode); //append the value to LI
text = document.getElementById("demo")// " demo " is the Un-order list id
console.log(text) ;
document.getElementById("demo").appendChild(node); //append the value to UI
document.querySelector("input").value = ""
}
}