trying to understan promises... I have this
async function fetchUsers(idUser) {
const result = await User.forge({id: idUser}).fetch({columns:['name']});
return result
}
router.get('/users', (req, res) => {
const userData = {
iduser: req.userId,
}
Orders.getOrders(userData, (err, rows) => {
if (err) {
console.log(err);
}
let user = fetchUsers(req.userId);
console.log(user)
console.log('-------------------------------');
console.log(rows)
res.json({orders: rows});
});
});
And I´m getting promise { } in the console.log(user)
. Shouldn´t this work with async/await or I am using it wrong?