[英]aws DynamoDB getItem InvalidParameterType error
I've been trying to communicate my ReactJS app with aws DynamoDB, but keeps getting InvalidParameterType error.我一直在尝试将我的 ReactJS 应用程序与 aws DynamoDB 通信,但一直收到 InvalidParameterType 错误。 apikey, secret key and region have been confirmed correct.
apikey、secret key 和 region 已确认正确。 Skip the UI part, I've tried hard-code the request
Key
to params
so the error doesn't come from other parts.跳过 UI 部分,我已尝试将请求
Key
硬编码为params
因此错误不会来自其他部分。 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'):错误是(跳过关键'0'到'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']
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如下所示: http : //docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB.html#getItem-property
You can use AWS.DynamoDB.DocumentClient
to avoid having to specify types.您可以使用
AWS.DynamoDB.DocumentClient
来避免指定类型。
http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#get-property http://docs.aws.amazon.com/AWSJavaScriptSDK/latest/AWS/DynamoDB/DocumentClient.html#get-property
var AWS = require('aws-sdk');
var client = new AWS.DynamoDB.DocumentClient({apiVersion: '2012-08-10'});
var params = {
TableName: "customer",
Key:
{
"email" : "12345@qwerrrr.com"
}
};
client.get(params, function(err, data) {
if(err){
console.log(err);
}else{
console.log(data)
}
});`
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.