Answer the question
In order to leave comments, you need to log in
How to call return on parent?
Hello!
Please, help! I haven’t eaten or slept for two days, but I don’t understand HOW!
There is a Use.js code
exports.checkUser = function () {
let user = new User({
username: arguments[0],
password: arguments[1]
});
User.findOne({username: user.username})
.then(function (doc) {
let uid;
if (find) {
if (user.checkPassword(find.salt, find.hashedPassword)) {
uid = user.rsaEncrypt(arguments[2], find._id);
console.log("12");
if (arguments.length === 3) {
console.log("1");
console.log(uid);
return Promise.resolve(uid);
} else if (arguments.length === 4) {
console.log("2");
console.log(uid);
return uid === arguments[3];
}
} else return false;
} else return false;
});
};
res.send(User.checkUser(req.body.username, req.body.pwd, req.ip));
return
, but no matter how I try - it does not work! Answer the question
In order to leave comments, you need to log in
Read about Promise
return User.findOne
User.checkUser().then(result => {
res.send(result);
}).catch(err => {
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question