小编Mar*_*etz的帖子

如何宣传AWS JavaScript SDK?

我想使用promises在JavaScript中使用aws-sdk.

而不是默认的回调样式:

dynamodb.getItem(params, function(err, data) {
  if (err) console.log(err, err.stack); // an error occurred
  else     console.log(data);           // successful response
});
Run Code Online (Sandbox Code Playgroud)

我想要使​​用承诺风格:

dynamoDb.putItemAsync(params).then(function(data) {
  console.log(data);           // successful response
}).catch(function(error) {
  console.log(err, err.stack); // an error occurred
});
Run Code Online (Sandbox Code Playgroud)

node.js promise amazon-dynamodb bluebird aws-sdk

41
推荐指数
6
解决办法
2万
查看次数

从AWS Lambda调用时,AWS DynamoDB会返回验证错误

我正在使用AWS Lambda并尝试向AWS DynamoDB写入内容.我使用以下代码:

var tableName = "locations";
var item = {
    deviceId: {
        S: event.deviceId
    },
    timestamps: {
        S: event.timestamp 
    }
}
var params = {
    TableName: tableName,
    Item: item
};

dynamo.putItem(params, function(err, data) {
    if (err) {
        context.fail(new Error('Error ' + err));
    } else {
        context.success(null);
    }
});
Run Code Online (Sandbox Code Playgroud)

我收到以下错误:

returns Error ValidationException: One or more parameter values were invalid: Type mismatch for key deviceId expected: S actual: M
Run Code Online (Sandbox Code Playgroud)

amazon-web-services amazon-dynamodb aws-lambda

10
推荐指数
1
解决办法
1万
查看次数