var results;
var sql = 'SELECT * FROM avg_table WHERE id = ?';
connection.query(sql, [id], function (err, result) {
if (err) throw err;
results = JSON.stringify(result);
});
return results;
};
module.exports = { listRecord};
Hello. When i try to read returned results data from another file it says undefined. I import like this down below
const dbHandler = require('./dbHandler');
and im trying to use like this
.route('/')
.get(function (req, res) {
res.send('Kayit Listele');
console.log(dbHandler.listRecord(req.query.id));
})
Couldn't find any way to fix this. Than you everyone for helping