Skip to content

Instantly share code, notes, and snippets.

@lsegal
Created March 7, 2014 20:59
Show Gist options
  • Save lsegal/9420007 to your computer and use it in GitHub Desktop.
Save lsegal/9420007 to your computer and use it in GitHub Desktop.
Uses promises with the AWS SDK for JavaScript
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
var Q = require('q');
var list = Q.nbind(s3.listBuckets.bind(s3));
list().then(function(data) {
console.log(data);
});
var AWS = require('aws-sdk');
var s3 = new AWS.S3();
var promisify = require('when-promisify');
var list = promisify(s3.listBuckets.bind(s3));
list().then(function(data) {
console.log(data);
});
// alternate method
var list = promisify(s3, 'listBuckets');
list().then(function(data) {
console.log(data);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment