Pramod Gaikwad
Pramod Gaikwad

Reputation: 185

Reference Error: docClient is not defined

When inserting item into dynamo db local table using AWS java script interface for dynamo db getting error docClient is not defined. How to initialize docClient? Below is the code which cause problem.

enter var params = {
TableName: "ADV_Admin",
Item: { "jdate": 45455455411444411,"name": "xyz abc", "pwd": sdewrfsdzs",
  "roles": "[\"ADMIN\",\"USER\"]",  "st": "R",  "uname": "admin"}
};

docClient.put(params, function(err, data) {
if (err)
    console.log(JSON.stringify(err, null, 2));
else
    console.log(JSON.stringify(data, null, 2));
});

Upvotes: 0

Views: 1620

Answers (1)

Peter Fennema
Peter Fennema

Reputation: 1690

Before you use docClient you will have to define it somewhere, as follows:

var AWS = require('aws-sdk'); // you probably have this line somewhere already    
var docClient = new AWS.DynamoDB.DocumentClient();

Upvotes: 1

Related Questions