考虑来自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"
}