Querying DynamoDB with Lambda does nothing

前端 未结 6 897
北恋
北恋 2021-02-07 09:01

I have the following code for a Lambda function:

console.log(\'Loading function\');
var aws = require(\'aws-sdk\');
var ddb = new aws.DynamoDB();

function getUs         


        
6条回答
  •  自闭症患者
    2021-02-07 09:39

    So, it turns out that the code is correct. The problem is that the dynamodb API uses all those callbacks and basically the function ends BEFORE the data has been retrieved.

    The quickest fix is to remove the context.succeed() call and the data will be retrieved. Of course using the async module would help and if you don't want to use that, just add a counter or a boolean to your callback and then wait until the value has changed, indicating that the callback has been called (which kind of sucks if you think of it)

提交回复
热议问题