1 Resposta
- Mais recentes
- Mais votos
- Mais comentários
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);
});
Conteúdo relevante
- AWS OFICIALAtualizada há um ano
- AWS OFICIALAtualizada há um ano