V
V
Vladimiros2017-04-02 20:57:47
MySQL
Vladimiros, 2017-04-02 20:57:47

Select query in mySQL from node.js?

I make a request for a selection in the database and in response to the console output "[object Object]"
Here is the script:

const mysql = require("mysql");

const connection = mysql.createConnection({
  host:"localhost",
  user:"admin",
  password:""
});

connection.connect();
connection.query('use callback');
connection.query("SELECT 'msg' FROM NewMessage LIMIT 1", function(err, result){
    if(err) return console.log(err);
    console.log(result);
});

connection.end(function(err){
  if(err) return console.log(err);
  
  console.log("Disconnect");
});

I can not understand how to get a normal response or decode. I'm new to programming, so I apologize for the wording.

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