tedder42 tedder42 - 9 months ago 58
Javascript Question

No data returned in a aws-sdk Promise

I'm calling DynamoDB's PutItem as my first es6 promises attempt on AWS Lambda with Node 4.3.

Here's the relevant code:

var req = d.putItem(params={
'TableName': TABLE,
req.then(function(resp) {
console.log("sresp", resp);
// I want to do more with the returned data here

And here's what shows up in the console:

sresp {}

There are a few questions about Promises in the AWS SDK (javascript) that are from the "pre-promises" era; as of March 2016 there's native support.


DynamoDB putItem request doesn't return anything by default. You have to specify a value for one or more of the following parameters in order to get something back (they all default to NONE):

  ReturnConsumedCapacity: 'INDEXES | TOTAL | NONE',
  ReturnItemCollectionMetrics: 'SIZE | NONE',