My current code works. However, it doesn't work exactly how I want it to work. Right now, my app is calling sendVerificationEmail
, which is my own cloud function. Inside my cloud function, I'm calling sendCustomVerificationEmail
, which is an Amazon Simple Email Service (SES) function.
I don't want my cloud function to return anything to my app until the SES function has confirmed that an email has been sent. How do I do this?
exports.sendVerificationEmail = functions.https.onCall((data, context) => {
var emailAddress = data.emailAddress;
var params = {
EmailAddress: emailAddress,
TemplateName: "MyAppVerificationEmail"
};
ses.sendCustomVerificationEmail(params, function(err, data) {
if(err) {
console.log(err);
return err
}
else {
console.log(data);
// THIS IS WHERE I WANT MY CLOUD FUNCTION'S RETURN STATEMENT!
}
});
return "Verification email sent."
// I WANT TO MOVE THIS RETURN STATEMENT SO THAT IT'S CALLED ONLY AFTER THE ABOVE SES FUNCTION FINISHES
});
--- Thanks in advance! ---