Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Uncaught reference error: AWS not defined

I have been trying to implement DynamoDB using Javascript. When I used, AWS.config.update='my_region', I'm getting "uncaught referenceerror: AWS in not defined". I have declared AWS globally.

Note: aws.sdk.js has been implemented

like image 714
Vignesh S Avatar asked Jul 28 '17 09:07

Vignesh S


2 Answers

If you are using node.js aws sdk, you should include the require.

var AWS = require("aws-sdk");
var creds = new AWS.Credentials('akid', 'secret', 'session');

AWS.config.update({
    region: "us-west-2",
    endpoint: "http://localhost:8000",
    credentials: creds
});

If you are using JavaScript in HTML, please include the SDK.

<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js"></script>

If the above solution doesn't resolve the issue, please show your full code to look at your scenario specifically.

Javascript Example

like image 68
notionquest Avatar answered Oct 28 '22 00:10

notionquest


One Crucial Mistake I was doing is not to add
<script src="https://sdk.amazonaws.com/js/aws-sdk-2.1.12.min.js"></script> this line in my html code(for front-end side in angular2). If you are using NodeJS then you have to add this file by using npm install aws-sdk.

You can find this information in this link.

like image 4
Pratik Gandhi Avatar answered Oct 27 '22 23:10

Pratik Gandhi