Node.js &引用;Runtime.HandlerNotFound:sendEmail.handler未定义或未导出";我发现了这个错误。有人能告诉我怎么解决吗
const AWS=require('AWS-sdk'); const SES=新的AWS.SES() const FROM_EMAIL_ADDRESS=process.env.FROM_EMAIL_ADDRESS; const TO_EMAIL_ADDRESS=process.env.TO_EMAIL_ADDRESS 函数sendmailtome(formData){ } exports.sendmail=async(事件)=>{ log('sendmail called')Node.js &引用;Runtime.HandlerNotFound:sendEmail.handler未定义或未导出";我发现了这个错误。有人能告诉我怎么解决吗,node.js,aws-lambda,amazon-dynamodb,Node.js,Aws Lambda,Amazon Dynamodb,const AWS=require('AWS-sdk'); const SES=新的AWS.SES() const FROM_EMAIL_ADDRESS=process.env.FROM_EMAIL_ADDRESS; const TO_EMAIL_ADDRESS=process.env.TO_EMAIL_ADDRESS 函数sendmailtome(formData){ } exports.sendmail=async(事件)=>{ log('sendmail called') }您指定lamb
}您指定lambda的入口函数称为
处理程序
。但是,代码中没有处理程序
函数。这就是为什么会出现此运行时错误。应该在lambda中运行的函数必须被称为handler。谢谢,我更改了它,但出现了此错误。。无法读取未定义的属性“0”。这是另一个问题。您的活动似乎没有“记录”属性。好的,非常感谢您的回答对您有所帮助,您愿意接受吗?
const emailParams = {
Source: FROM_EMAIL_ADDRESS,
ReplyToAddresses: [TO_EMAIL_ADDRESS],
Destination: {
ToAddresses: [TO_EMAIL_ADDRESS],
},
Message: {
Body: {
Text: {
Charset: 'UTF-8',
Data: `Thanks for subscription: ${formData.message}\n\n Name: ${formData.name}\n Email: ${formData.email}\n I will reply as soon as possible`,
},
},
Subject: {
Charset: 'UTF-8',
Data: 'New message from your_site.com',
},
},
};
console.log(emailParams)
const promise = SES.sendEmail(emailParams).promise();
console.log(promise);
return promise
const dynamodb = event.Records[0].dynamodb;
console.log(dynamodb);
const formData = {
name : dynamodb.NewImage.name.S,
message : dynamodb.NewImage.message.S,
email : dynamodb.NewImage.email.S
}
console.log(formData);
return sendEmailToMe(formData).then(data => {
console.log(data);
}).catch(error => {
console.log(error);
});