I cant seem to query my dynamodb through lambda. The error message shows: ERROR Unable to scan the table. Error JSON: { "message": "Invalid FilterExpression: An expression attribute value used in expression is not defined; attribute value: :coloursavailable", My code is as follows:
async function dispatch(intentRequest, callback) {
const aws = require('aws-sdk');
aws.config.update({region: 'xxx'});
var ddb = new aws.DynamoDB();
var ddbDocClient = new aws.DynamoDB.DocumentClient()
async function getCost(colour,size) {
var params ={
TableName : "XXX",
ProjectionExpression:"Cost",
FilterExpression: "coloursavailable = :coloursavailable and sizesavailable = :sizesavailable",
ExpressionAttributeValues:{ ":coloursavailable" : colour, ":sizesavailable": size}
}
return new Promise(resolve =>{
ddbDocClient.scan(params, onScan)
function onScan(err, data) {
if (err) {
console.error("Unable to scan the table. Error JSON:", JSON.stringify(err, null, 2));
} else {
data.Items.forEach(function(item) {
resolve(item.Cost);
});
}
}
})
}
Thanks in advance!