Below code I have mentioned where i am getting undefined and where i am getting the resul can you help me understand what I am doing wrong.
const Connection=require('../utilities/connection')
let db={}
let data;
db.findall=async()=>{
Connection.query("select * from offers;", (err, rows, _field) => {
if (!err) {
data=rows;
//console.log(row)---> this give correct output
}
else {console.log("Error while fetching");}
});
//console.log(data)-->undefined
}
async function run(){
await db.findall()
console.log(data);//undefined
}
run()
// module.exports=db