【发布时间】:2019-08-05 05:43:09
【问题描述】:
我正在创建一个系统,该系统使用 API 检查玩家数据,然后更新到我的 DynamoDB,但似乎中途停止了?因为Let's scan our players & update stats! 从未显示在我的日志中?
exports.handler = async (event, context) => {
var documentClient = new AWS.DynamoDB.DocumentClient();
var params = {
TableName: 'games',
FilterExpression:'updated_at = :updated_at',
ExpressionAttributeValues: {
":updated_at": 0,
}
};
var rows = await documentClient.scan(params).promise();
let gameAPI = new GameAPI();
await gameAPI.login().then(function() {
console.log("We have logged into our game!");
rows.Items.forEach(function(match) {
console.log("Let's look at our match! " + match.id);
var player_params = {
TableName: 'players',
FilterExpression:'match_id = :match_id',
ExpressionAttributeValues: {
":match_id": match.id,
}
};
documentClient.scan(player_params).promise().then(row => {
console.log("Let's scan our players & update stats!");
});
});
});
};
我假设这与我的 async 和 await 函数有关?有人能指出我正确的方向吗?
【问题讨论】:
-
你好像混用了
await和.then,有什么原因吗? -
@OllysCoding 不,我对异步的东西不是很先进;所以这是混搭哈哈
标签: node.js asynchronous lambda amazon-dynamodb async.js