error using require.js to load aws-sdk databse script

Viewed 13

I'm trying to require aws sdk database for use in a web application, but I'm getting the following errors

const AWS = require(["aws-sdk"]);
AWS.config.update({ region: "ap-southeast-2" });

AWS.config.update({
    region: "{Region[enter image description here][1]}",
    // For security reasons, do not store AWS Credentials in your files. Use Amazon Cognito instead.
    accessKeyId: "{Key}",
    // secretAccessKey default can be used while using the downloadable version of DynamoDB.
    // For security reasons, do not store AWS Credentials in your files. Use Amazon Cognito instead.
    secretAccessKey: "{Key}"
});
1 Answers

You're using the wrong syntax, passing an array to require is part of the callback syntax and expects a function as a second argument.

Try this instead:

const AWS = require("aws-sdk");

Also, I'm not sure why you're calling config.update twice, you probably should just do it once to avoid any issues, or at a minimum to avoid confusion.

Related