通过蓝鸟宣传aws-sdk

时间:2015-03-09 22:50:42

标签: node.js bluebird aws-sdk

伙计们,我能够简单地打电话给SES:

var Promise = require("bluebird");
var AWS = require('aws-sdk');
var SES = new AWS.SES();

SES.listVerifiedEmailAddresses(function (err, emails) {
    console.log(err,emails);
});

但是,当我尝试使用bluebird时,我会得到以下内容:

var Promise = require("bluebird");
var AWS = require('aws-sdk');
var SES = new AWS.SES();
var ses = Promise.promisifyAll(Object.getPrototypeOf(SES));
ses.listVerifiedEmailAddressesAsync().then(function (err,emails) {
    console.log('p',err,emails);
});

错误:

Unhandled rejection TypeError: Cannot read property 'params' of undefined

那么,如何通过蓝鸟宣传aws-sdk?需要能够return成功承诺的结果。

谢谢!

1 个答案:

答案 0 :(得分:2)

以下位有效,谢谢@victorkohl

var SES = new Promise.promisifyAll(new AWS.SES());

SES.listVerifiedEmailAddressesAsync().then(function (err,emails) {
    console.log('p',err,emails);
});