Gerard Taub Gerard Taub - 1 month ago 28
React JSX Question

aws DynamoDB getItem InvalidParameterType error

I've been trying to communicate my ReactJS app with aws DynamoDB, but keeps getting InvalidParameterType error. apikey, secret key and region have been confirmed correct. Skip the UI part, I've tried hard-code the request

Key
to
params
so the error doesn't come from other parts. the related code is:

var AWS = require('aws-sdk');
var client = new AWS.DynamoDB({apiVersion: '2012-08-10'});
var params = {
TableName: "customer",
Key:
{
"email" : "12345@qwerrrr.com"
}
}
client.getItem(params, function(err, data) {
if(err){
console.log(err);
}else{
console.log(data)
}
});`


error is(skipping the same parts that's key '0' to '16'):

Error: There were 18 validation errors:
* InvalidParameterType: Expected params.Key['email'] to be a structure
* UnexpectedParameter: Unexpected key '0' found in params.Key['email']


my dynamoDB looks like this:
enter image description here

Answer

Your key parameter should look something like this:

Key : { 
  "email" : {
    "S" : "12345@qwerrrr.com"
  }
}

As seen here: http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#getItem-property

Comments