Promisify aws-sdk through the blue bird

People, I can make a simple SES call:

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

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

However, when I try to use bluebird, I get the following:

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);
});

Error:

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

So how can you promise aws-sdk via bluebird? You need to have the returnresults of successful promises.

Thank!

+4
source share
1 answer

The next bit works, thanks @victorkohl

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

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

All Articles