I have a dynamodb
query in nodejs as follows. I have a matching record
but its not returning any values. Any idea to resolve the problem?
const docClient = new AWS.DynamoDB.DocumentClient({ region: "ap-south-1" });
var userParams = {
TableName: "aa-users",
FilterExpression: '#email = :emailval AND #postProfileOTP = :otpval',
ExpressionAttributeNames: {
"#email": "email",
"#postProfileOTP": "postProfileOTP"
},
ExpressionAttributeValues: {
":emailval": email,
":otpval": otp
}
};
docClient.scan(userParams, function (err, data) {
console.log(data.Count) // not getting the result count
if(data.Count > 0){
res.status(200).json({ "status": 1, "data": data.Items })
}
})
Instead am getting the error as follows:
2020-01-24T11:56:20.554Z ee0fd306-6bd5-4cf0-957e-732b08c6b0e3 ERROR Uncaught Exception { "errorType": "TypeError", "errorMessage": "Cannot read property 'Count' of null", "code": "TypeError", "message": "Cannot read property 'Count' of null", "time": "2020-01-24T11:56:20.554Z", "stack": [ "TypeError: Cannot read property 'Count' of null", " at Response. (/var/task/handler.js:351:18)", " at Request. (/var/task/node_modules/aws-sdk/lib/request.js:364:18)", " at Request.callListeners (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:106:20)", " at Request.emit (/var/task/node_modules/aws-sdk/lib/sequential_executor.js:78:10)", " at Request.emit (/var/task/node_modules/aws-sdk/lib/request.js:683:14)", " at Request.transition (/var/task/node_modules/aws-sdk/lib/request.js:22:10)", " at AcceptorStateMachine.runTo (/var/task/node_modules/aws-sdk/lib/state_machine.js:14:12)", " at /var/task/node_modules/aws-sdk/lib/state_machine.js:26:10", " at Request. (/var/task/node_modules/aws-sdk/lib/request.js:38:9)", " at Request. (/var/task/node_modules/aws-sdk/lib/request.js:685:12)" ] }