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);
}
}