Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

248
Views
how to make AWS dynamo db work in nodejs in using async await

I have this sample dynamo db create data code

var AWS = require("aws-sdk");
let awsConfig = {
    "region": "ap-south-1",
    "endpoint": "http://dynamodb.ap-south-1.amazonaws.com",
    "accessKeyId": "xxxxxxxxxxxxxxxxx", "secretAccessKey": "xxxxxxxxxxxxxxxxxxxxxxx"
};
AWS.config.update(awsConfig);

let docClient = new AWS.DynamoDB.DocumentClient();

console.log(docClient);

let save = function () {

    var input = {
        "task": "example-1@gmail.com"
    };
    var params = {
        TableName: "todos",
        Item:  input
    };
    docClient.put(params, function (err, data) {

        if (err) {
            console.log("error - " + JSON.stringify(err, null, 2));                      
        } else {
            console.log(data);
        }
    });
}



save();

Now I converted this into async-await form

const create = async (docClient,payload,tableName) =>{
    try {
        console.log(payload);
        const createdDoc = await docClient.put({TableName:tableName,Item:payload})
        console.log(createdDoc);
    } catch (error) {
       console.log(error); 
    }
}
        


create(docClient,{"task":"sample"},"todos")

This code neither gave me an error neither it add data into dynamo DB tables

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

You have to call .promise() on the result of .put() call:

const createdDoc = await docClient.put({ … }).promise();

See docs for AWS.DynamoDB.DocumentClient.put() and AWS.Request.promise().

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!