如何保证AWS JavaScript SDK的安全性? [英] How do I promisify the AWS JavaScript SDK?

查看:78
本文介绍了如何保证AWS JavaScript SDK的安全性?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

I want to use the aws-sdk in JavaScript using promises.

代替默认的回调样式:

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

我想使用一种承诺样式:

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

推荐答案

我相信现在可以在.promise()后面附加调用,以实现给定方法的实现.

I believe calls can now be appended with .promise() to promisify the given method.

您可以看到它在2.6.12中开始引入 https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md#2612

You can see it start being introduced in 2.6.12 https://github.com/aws/aws-sdk-js/blob/master/CHANGELOG.md#2612

您可以在AWS博客 查看全文

登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆