使用ExclusiveStartKey时的API Gatway代理响应

时间:2018-10-21 21:38:05

标签: javascript node.js callback amazon-dynamodb aws-api-gateway

考虑来自Amazon DynamoDB文档的this example,在这里我们有:

dynamoDb.scan(params, onScan);

function onScan(err, data) {
      if (err) {
          return;
      } else {
        collectedItems.push(data.Items);

        const response = {
          statusCode: 200,
          headers: {
            'Access-Control-Allow-Origin': '*',
          },
          body: JSON.stringify(collectedItems),
        };
        callback(null, response);

        // continue scanning if we have more movies, because
        // scan can retrieve a maximum of 1MB of data
        if (typeof data.LastEvaluatedKey != "undefined") {
            console.log("Scanning for more...");
            params.ExclusiveStartKey = data.LastEvaluatedKey;
            dynamoDb.scan(params, onScan);
        }



      }
  }

应该向我显示collectedItems作为API网关的json响应。但它返回

{
 message: "Internal server error"
}

0 个答案:

没有答案