First of all, forgive me about the title couldn't think of an appropriate title.
const product = products.findOne({_id}, (error, productFound) => {
console.log(productFound.name);
return {...productFound};
});
console.log(product.name);
the log
inside findOne
method do return me a true value, but the log
outside the findOne
function returns undefined
.
why is that and how can I get the data outside the findOne
function?