2016-10-08 5 views
0

내 ReactJS 응용 프로그램을 aws DynamoDB와 통신하려고했지만 InvalidParameterType 오류가 계속 발생합니다. apikey, 비밀 키 및 지역이 올바른지 확인되었습니다. UI 부분을 건너 뛰고, 요청을 Key에서 params으로 하드 코딩하려고 했으므로 다른 부분에서 오류가 발생하지 않습니다. 관련 코드는 다음과 같습니다aws DynamoDB getItem InvalidParameterType 오류

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

오류 ('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'] 

내 DynamoDB의는 다음과 같습니다 enter image description here

답변

0

유형을 지정하지 않아도되도록 AWS.DynamoDB.DocumentClient을 사용할 수 있습니다.

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" : "[email protected]" 
    } 
}; 
client.get(params, function(err, data) { 
    if(err){ 
     console.log(err); 
    }else{ 
     console.log(data) 
    } 
});` 
관련 문제