0

New to Dynamo DB and have spent a bit of time searching Stackoverflow for my issue but not having any luck. I currently have a pretty default setup table have some data being populated in (confirmed by using the item explorer tab in the console). I was referencing the AWS Dynanmo SDK and also this post stackOverflow 44589967 to basically return the first item from the table. Does not matter which item just any item. So here is very basic lambda, and I did confirm permissions:

const AWS = require('aws-sdk');
const ddb = new AWS.DynamoDB.DocumentClient({region: 'us-east-1'});
exports.handler = async function(event, context) {
   let result = await ddb.scan({
        "TableName": "DynamoDB_Project",
        "Limit": 1,
      })

console.log(result);
}

I am getting null and wondering if its actually how I am storing the data

screen shot of table explorer

which is similar to my scan

await ddb.put({
        "TableName": "DynamoDB_Project",
        "DateTempHumid": {
            "Date": event.date,
            "Humidty": event.humidty,
            "Temperature": event.temperature
          },
      })

1 Answers1

0

Did you forget to add the .promise() function to the string of calls?

const AWS = require('aws-sdk');
const ddb = new AWS.DynamoDB.DocumentClient({region: 'us-east-1'});
exports.handler = async function(event, context) {
   let result = await ddb.scan({
        "TableName": "DynamoDB_Project",
        "Limit": 1,
      }).promise(); // HERE

    console.log(result);
}

Hope that helps

mkamioner
  • 2,451
  • 1
  • 17
  • 14