DyanmoDB getItem not providing any response within Async Lambda

I have been trying to make a getItem request in an async Lambda function to dynamo DB, and I am not receiving any response at all. Any troubleshooting or help would be greatly appreciated.

in general, I am trying to make a request to a dynamodb table using the AWS SDK getItem, however, when I run my code there is no response for the await ddb.getItem function

so I am kinda lost as to what could be causing this.

// Load AWS SDK const AWS = require("aws-sdk"); // Set the region AWS.config.update({ region: "us-east-1" });  // Create the DyanmoDB service object const ddb = new AWS.DynamoDB({ apiVersion: "2012-08-10" });  const handler = async (   event,   context,   callback,   test = false,   testObjFunc = {     test: () => {       Error("Testing enabled");     }   } ) => {   const response = {     isBase64Encoded: false,     statusCode: 200,     headers: { "Content-Type": "application/json", "Access-Control-Allow-Origin": "*" },     multiValueHeaders: {},     body: JSON.stringify({ responseBody })   };    try {     // Parameters for DynamodDB getItem call     const dbParams = {       TableName: "Table_Name",       Key: {         personID: { S: "value" }       },       ProjectionExpression: "value_to_return"     };      // DynamoDB call to check for item     const results = await ddb.getItem(dbParams).promise();     console.log("success");     console.log(results);    } catch (error) {     response.statusCode = 500;   }    return response; }; module.exports.handler = handler;   
Add Comment
1 Answer(s)

You have put the getitem call in try block, as you are not receiving any response means something is gone wrong in the try block.

Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.