fetch(sql) {
let answer = [];
db.execute(sql, function (err, result) {
if (err) throw err;
console.log("From DB");
answer.push(result);
});
return answer;
}
let sql = "SELECT * from employees";
let result = fetch(sql);
console.log(result);
When I call this fetch function, I get an empty list. I want that the results should be pushed into the list first and then the list should be returned. All the db configurations are correct and the results are being fetched but they are not pushed into the list.