Mongoose result property is undefined but exist
I am facing a strange case. This is the second time you face this problem. I added a comment after each console.log to see the results:
Spain.find()
.limit(5)
.exec((findErr, results) => {
if(findErr){
console.log('error while login', findErr);
} else if(!results) {
console.log('err with res');
} else {
let pool = 0;
results.forEach((res, index) => {
pool -= 1000;
console.log(res); // {test1: 10, test2: 30, test3:20}
let max = Math.max(res.test1, res.test2, res.test3);
console.log(res.test1, res.test2, res.test3); // undefined undefined undefined
console.log('max', max); // NaN
});
}
});
Any idea how this is possible?
UPDATE:
This code works like a working one, maybe this is the question ...
Node.js version: 7.10.1, mongoose version: 4.11.4
UPDATE 2: The code is in the typescript class. - Maybe a parser error?
+3
source to share
No one has answered this question yet
See similar questions:
or similar: