A
A
antoxapunisher2019-03-27 19:23:11
MySQL
antoxapunisher, 2019-03-27 19:23:11

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

In the console it displays the values ​​correctly, but on the web page it displays 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>';  //я так понимаю тут нужно что-то изменить
      data = data.replace("{rezc}", rezc);
      response.end(data);
      });
});
});

When counting the number of lines, it outputs everything perfectly.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question