Daryn Daryn - 1 year ago 174
Node.js Question

AWS.DynamoDB.DocumentClient is not providing data on put

I am using the AWS.DynamoDB.DocumentClient, with Dynamodb local (port 8080). When I perform a put, the

variable in the callback is an empty object. Have I missed something?

import * as AWS from "aws-sdk";

region: "us-west-2",
endpoint: "http://localhost:8080"

const docClient: any = new AWS.DynamoDB.DocumentClient();

const item = {
someField: "456",
other: "123"

const params = {
TableName: "TableName",
Item: item

docClient.put(params, function(err, data) {
if (err) console.log(err);
else console.log(data); // this produces: {}

There is no error, and the item is being inserted\updated - however the
variable is an empty object. Shouldn't this contain values?


Answer Source

You aren't asking for any values to come back, so why do you expect there to be any values coming back? You'll need to set the appropriate parameters ReturnConsumedCapacity and/or ReturnItemCollectionMetrics and/or ReturnValues if you are wanting any of that to come back in the response.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download