Reputation: 589
I use Mongoose 4.1.11
It's very very hard to perform this bug :
console.log("step1"); // that's display every time in my console => ok
models.users.findOne({email: mail}, function (err, myUser) {
console.log("step2"); // That's very very weird, that's work but RARELY that's doesn't work
...
Sometimes, my API server doesn't work because of this problem,
Edit #1
so, I changed my server hosting from Gandi to Heroku. And now, its works very well ! Thank you for your help ;-)
Upvotes: 0
Views: 11023
Reputation: 589
so, I changed my server hosting from Gandi to Heroku. And now, its works very well ! Thank you for your help ;-)
Upvotes: 0
Reputation: 1126
var User = mongoose.model('User', UserSchema);
User.findOne({email: mail}, function (err, myUser) {
console.log("step2"); // That's very very weird, that's work but RARELY that's doesn't work
}
Upvotes: 2
Reputation: 1947
You should use err callback arguments, like below;
models.users.findOne({email: mail}, function (err, myUser) {
if (!err) console.log("step2"); // That's very very weird,that's work but RARELY that's doesn't work
else console.log(err.message);
...
Mongo generate error object when somethings went wrong and you can get error's reason in this usage.
Upvotes: 2