I am having trouble returning some database values to my server in nodejs, it seems that on the way the values are lost.
result is loged fine and i am findining my data, but it is lost in the return.
exports.getProducts = async function () {
return await MongoClient.connect(url, {useNewUrlParser: true}, async function
(err, client) {
let db = client.db(dbName);
return await db.collection('products').find({}).toArray(async function (err,
result) {
if (err) throw err;
client.close();
console.log(result);
return await result
});
});
}