尝试将AWS开发工具包用于节点,但出现此错误未捕获的错误:“ aws-sdk”的脚本错误 这是我的代码。我尝试使用require('aws-sdk'),但是控制台错误不是说使用require([],()=> {}) 我从npm下载了require和aws-sdk
require(['aws-sdk'], (AWS) => {
let email = document.getElementById('footerEmail');
let emailSubmit = document.getElementById('footerButton');
AWS.config.update({ region: 'us-east-1' });
let sns = new AWS.SNS();
let params = {
Protocol: 'email', /* required */
TopicArn: 'arn:aws:sns:us-east-1:274999247491:HouseRoots', /* required */
Endpoint: email.value,
ReturnSubscriptionArn: false
};
console.log('h');
emailSubmit.addEventListener('click', () => {
console.log('h');
sns.subscribe(params, function (err, data) {
if (err) {
email.value = "error occured";
console.log(err);
}
else {
email.value = "confirmation sent";
}
});
console.log('h');
});
});
答案 0 :(得分:1)