1 Antwort
- Neueste
- Die meisten Stimmen
- Die meisten Kommentare
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);
});
Relevanter Inhalt
- AWS OFFICIALAktualisiert vor 2 Jahren
- AWS OFFICIALAktualisiert vor einem Jahr