Writes the undefined value Node.js MySql, how to fix?

In the console displays the values correctly, and the web page outputs the value undefined.

Console:
5c9ba052dde0c132759892.jpeg
app.get("/order.html", function(request, response){
con.query("SELECT Sum(Cost) FROM Orders", function (err, result, fields) {
 if (err) throw err;
console.log(result);
 let rezc = ";
 fs.readFile("crm/order.html", "utf8", function(error, data){
 rezc += '<p>'+result[0].cost+'</p>'; //I understand you need something to change
 data = data.replace("{rezc}", rezc);
response.end(data);
});
});
});


When counting the number of lines that displays everything perfectly.
March 19th 20 at 08:54
0 answer

Find more questions by tags Node.jsJavaScriptMySQL