var email;
findEmail = (n, un, pw, item) => {
User.findOneAndUpdate({name: n, username: un}, {$set:{password: pw}}, (err,info) => {
item(info.email);
});
};
findEmail(name, username, newPw, mail => console.log(mail)); // email@gmail.com
const name = req.body.name;
const username = req.body.username;
var email;
findEmail = (n, un, pw, item) => {
User.findOneAndUpdate({name: n, username: un}, {$set:{password: pw}}, (err,info) => {
item(info.email);
});
};
email = findEmail(name, username, newPw, mail => mail) ;
console.log(email); // undefined
it's print only console i want to store findEmail result value to email how to store..?