I'm trying to lift all the functions in an Amazon S3 object using when/node
.
var when = require('when');
var nodefn = require('when/node');
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
var promisedS3 = nodefn.liftAll(s3);
when(promisedS3.listBuckets())
.then(function(data) {
console.log(data);
})
However, it looks like a request object is being printed out. I'm kind of at a loss as to what is happening here, I can get the correct results if I individually lift functions like so:
var listBucketsP = nodefn.lift(s3.listBuckets.bind(s3));
Any ideas?
Try this:
Then just do
This worked for me.
Explanation: the methods you are trying to modify are not part of the
s3
object itself, but of its prototype. When'snode.liftAll
's 3 argument version takes the source object first, an optional transformation function, and finally the destination object (to attach the lifted functions onto).So we're taking the functions from the prototype and attach the promisified versions to the object we're working with.