Answer the question
In order to leave comments, you need to log in
Why does findOne() return undefined?
Hello!
I can’t understand, maybe someone has encountered such a problem,
why findOne () returns undefined?
When I just write lastOrder in the console, everything is fine (there is orderData and inside order: 3 )
module.exports.create = async (req, res) => {
try {
let lastOrder = await Order
.findOne({user: req.user.id})
// .sort({date: -1})
console.log(lastOrder);
Answer the question
In order to leave comments, you need to log in
orderData array, you need to specify the indexlastOrder.orderData[0].order
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question