I'm trying to lift an AWS S3 async function, and running into a weird error. Given the following code,
var s3 = new AWS.S3();
var when = require('when');
var nodefn = require('when/node');
var getObjectP = nodefn.lift(s3.getObject);
getObjectP({
Bucket: 'bucket_name',
Key: 'key_name'
})
.then(function(data) {
...
}, function(err) {
...
});
I get this error,
Object #<Object> has no method 'makeRequest'
Here's what the getObject
looks like normally (it works fine when I use callbacks instead of promises):
s3.getObject({ ... }, function(err, data) {
...
});
Am I misusing nodefn.lift
? It seems pretty straight-forward. Here's the docs for anyone interested. https://github.com/cujojs/when/blob/master/docs/api.md#nodelift
Probable the method has the wrong context, as it is not called as a method. Try to bind
it:
var getObjectP = nodefn.lift(s3.getObject.bind(s3));