I am trying to implement async/await module. In function2 if user is not present i want to stop the execution there . i dont want to execute function 3, if user present , i want to execute function3
const function1() {
//code
return a
}
const function2= (a,email) => model.user.findOne({ email:email}).then((user) => {
if (!user) {
****// want to stop execution here****
} else {
//update details of user
}
return dealer;
});
const function 3 = function(dealer) {
//mail sending
};
exports.mailer = async(email,callback) => {
try {
var a =await function1();
var dealer =await function2(a,email); //stop execution here
var res = await function 3(dealer);
await callback(res);
}catch (err){
callback(err);
}
}