Skip to content

Hack for adding the .promise() method to all aws-sdk request objects (aws-sdk is a peerDependency)

Notifications You must be signed in to change notification settings

Trioxis/aws-sdk-promise

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

aws-sdk-promise

Hack for adding the .promise() method to all aws-sdk request objects (aws-sdk is a peerDependency).

How it works?

Take a look at the source the short version its a terrible hack into the AWS.Request object (which aws-sdk returns from just about all api calls).

Usage

// AWS is identical to aws-sdk but it has .promise method on all
// requests
var AWS = require('aws-sdk-promise');
var ec2 = new AWS.EC2({ region: 'us-west-2' });

ec2.describeAccountAttributes({}).promise().then(
  function(req) {
    // the promise is resolved on the 'complete' event of request object
    console.log(JSON.stringify(req.data, null, 2));
  },
  function(error) {
    // rejected if the 'complete' event contains an error
    console.log(error);
  }
);

Credit: aws/aws-sdk-js#13 (comment)

About

Hack for adding the .promise() method to all aws-sdk request objects (aws-sdk is a peerDependency)

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%