Post Change Password Action

I am encountering a generic error message “Error! API Error. Please contact support if the problem persists” while running the code I have included below. Can anyone provide an explanation for the cause of this error?

Code:

const AWS = require(‘aws-sdk’);
const ses = new AWS.SES();

exports.onExecutePostChangePassword = async (event, api) => {
try {
const user = event.user;
const context = { request: event.request };
const { AWSCredentials } = context.clientMetadata;

      AWS.config.update({
        accessKeyId: AWSCredentials.accessKeyId,
        secretAccessKey: AWSCredentials.secretAccessKey,
        region: AWSCredentials.region
      });

      await sendPasswordChangedEmail(user , context);

  } catch (error) 
  {
      console.log(error)
  }

};

async function sendPasswordChangedEmail(user, context) {
const { email } = user;
const { request } = context;
// Send email using Amazon SES
const params = {
Destination: {
ToAddresses: [email]
},
Message: {
Body: {
Text: {
Data: “This email is to confirm that your password has been changed.”
}
},
Subject: {
Data: “Password Changed”
}
},
Source: ‘no-reply@gmail.com’,
};
try {
await ses.sendEmail(params).promise();
} catch (error) {
console.log(error);
}
}

Hey there!

As this topic is related to Actions and Rules & Hooks are being deprecated soon in favor of Actions, I’m excited to let you know about our next Ask me Anything session in the Forum on Thursday, January 18 with the Rules, Hooks and Actions team on Rules & Hooks and why Actions matter! Submit your questions in the thread above and our esteemed product experts will provide written answers on January 18. Find out more about Rules & Hooks and why Actions matter! Can’t wait to see you there!

Learn more here!