i am new at JS and Node. I am trying to make a task list in Expressjs. I have a bookshlef.js ODM. I traing to get all tasks from DB in function getAllTasks :
module.exports.getAllTasks = async function () {
let result = await Task.fetchAll();
result = result.toJSON();
console.log(result);
}
and it print all data in console, but if I am trying to return data from function getAllTasks
module.exports.getAllTasks = async function () {
let result = await Task.fetchAll();
result = result.toJSON();
return(result);
}
I get
Promise { <pending> }
I call it
var tasks = Application.getAllTasks();
console.log(tasks);
How can i return in getAllTasks a object with all data?