Answer the question
In order to leave comments, you need to log in
Why does return from a module return undefined?
Hello.
There is a code:
File1:
function doQuery(sql, array) {
pool.getConnection(function (err,mysql){
mysql.query(sql, array, function(err, res){
if(err) {
return `Error: ${err}`;
}
else {
return res;
}
});
mysql.release();
});
}
module.exports = {
query: doQuery
}
const db = require('./db-connect.js');
var test = db.query("SELECT * FROM users WHERE id = ?", [32]);
console.log(test);
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