1 回答
- 最新
- 投票最多
- 评论最多
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);
});
相关内容
- AWS 官方已更新 1 年前
- AWS 官方已更新 1 年前
- AWS 官方已更新 1 年前