Hello,
I’m implementing the auth verification email feature using Sendgrid integration and I’m facing the following issue: the email is sent twice, first one without any values populated (link
and name
) and second one with these values properly populated and a functioning link.
Front-end code (called from a form submit)
const handleSignupSubmit = async (event: SyntheticEvent) => {
....
....
try {
await signup(username, password, email); // react-moralis signup
await Moralis.Cloud.run('sendUserVerificationEmail', { name: username });
} catch (error) {
console.log(`${error instanceof Error && error.message}`);
}
};
I know you provide an alternative to Moralis.Cloud.run
in react-moralis
but I’d rather use the pure-JS API
Cloud function code (only called once as expected (according to the logs))
Moralis.Cloud.define('sendUserVerificationEmail', (request) => {
const logger = Moralis.Cloud.getLogger();
logger.info(`sendUserVerificationEmail: ${JSON.stringify(request)}`);
Moralis.Cloud.sendEmail({
to: request.user.get('email'),
templateId: 'd-d8....42',
dynamic_template_data: { name: request.params.name },
});
});
Emails received (I’ve hidden some data on purpose):
Thanks in advance for your help on this