Answer the question
In order to leave comments, you need to log in
Request to MySQL node.js?
Why does the function return an empty query? I understand that MySQL does not keep up with JS and an empty request comes in? Then how to get rid of it and get it not empty? How to write a function correctly?
function user(val) {
var sss='';
const connection = mysql.createConnection({
database: 'base',
host: "localhost",
user: "root",
password: ""
});
connection.query("SELECT * FROM `user` WHERE `uid`="+val+"",
function(err, results) {
console.log(results); //Тут все пришло!!!
console.log(err);
sss =results;
});
connection.end();
return sss;
}
console.info(user(31)); //Тут пусто!!!
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question