1 Risposta
- Più recenti
- Maggior numero di voti
- Maggior numero di commenti
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);
});
Contenuto pertinente
- AWS UFFICIALEAggiornata 2 anni fa
- AWS UFFICIALEAggiornata 2 anni fa
- AWS UFFICIALEAggiornata un anno fa