Uncaught Error: Script error for “aws-sdk”

匿名 (未验证) 提交于 2019-12-03 01:40:02

问题:

Trying to use the AWS SDK for node but I get this error Uncaught Error: Script error for "aws-sdk" Heres my code. I tried using require('aws-sdk'), but the console error than said to use require([],()=>{}) I downloaded both require and aws-sdk from npm

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

回答1:

I prepare you a basic sample app, press here.

For run:

  • npm install
  • node app.js
  • open browser localhost:3000/

You must have pre-configured:

  • aws_credentials file

  • you must change region in app.js (AWS.config.update({region: 'REGION'});)

  • the user must have to access SNS

Flow:



标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!