1 Answer
- Newest
- Most votes
- Most comments
1
This problem is caused by using both a callback and the .promise() method, like this:
await doc.get(params, function(err, data) {
if (err) {
console.error("Unable to read item. Error JSON:", JSON.stringify(err, null, 2));
} else {
myresult=data;
console.log("@@@@@@@@@"+data);
}
}).promise();
The problem is that every call in the DynamoDB API returns an object of type AWS.Request. The actual HTTP request gets sent only when you call the send() method. But passing a callback implicitly calls send(), and calling promise() implicitly calls it again. You can only call send() once.
The callback has to be turned into a .then() call.
await doc.get(params).promise()
.then(data=>{
myresult=data;
}).catch(err=>{
console.log(err);
});
Relevant content
- asked 5 months ago
- Accepted Answerasked 2 years ago
- asked 2 months ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated a year ago