I can't figure out why I don't see any response of the DynamoDB in my Alexa Skill.
I created several variations of the promise with DynamoDB from different sources to figure it out. But nothing seems to work. There is not even one error of the DynamoDB in the logs. This drives me crazy.
I tried scan, get and put operations.
Here the code of my scan try in AWS lambda:
....
'StartIntent': function () {
speechOutput = '';
var AWS = require('aws-sdk');
AWS.config.update({region: 'eu-west-1'});
var docClient = new AWS.DynamoDB.DocumentClient();
var params = {
TableName: "my_db_2",
FilterExpression: "data_type = card"
};
console.log("Scanning table.");
docClient.scan(params, onScan).promise().then(function(result) {
console.log("GetItem succeeded:", JSON.stringify(result, null, 2));
console.log("succeeded");
}).catch(error => {
console.log("ERROR catched");
});
console.log("scan done");
},
.....
function onScan(err, data) {
console.log("starting to scan");
if (err) {
console.error("Unable to scan the table. Error JSON:",
JSON.stringify(err, null, 2));
}
else {
console.log("Scan succeeded.");
data.Items.forEach(function(movie) {
console.log(movie.data_type);
});
}
}
Cloudwatch shows only:
2018-09-13T11:43:11.500Z Scanning table.
2018-09-13T11:43:11.522Z scan done
2018-09-13T11:43:11.659Z scan of 2nd done