promise を使用して 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
});
代わりにpromiseスタイルを使用したい:
dynamoDb.putItemAsync(params).then(function(data) {
console.log(data); // successful response
}).catch(function(error) {
console.log(err, err.stack); // an error occurred
});