Skip to content

Instantly share code, notes, and snippets.

@juniorb2ss
Last active January 24, 2017 00:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save juniorb2ss/c1e98dd5cf5d09321e72fdf1bc211978 to your computer and use it in GitHub Desktop.
Save juniorb2ss/c1e98dd5cf5d09321e72fdf1bc211978 to your computer and use it in GitHub Desktop.
'use strict';
var Promise = require('bluebird');
var AWS = require('aws-sdk');
// Check if environment supports native promises
if (typeof Promise === 'undefined') {
AWS.config.setPromisesDependency(require('bluebird'));
}
var getUserAsync = Promise.method(function(event, context, callback){
return new Promise(function(resolve, reject){
setTimeout(function(){ resolve(getUser(event, context, callback))}, 3000);
});
});
function getUser(event, context, callback){
console.log(event);
return 'getUser Function Promisse';
}
exports.handler = function (event, context, callback) {
getUserAsync(event, context, callback).then( function (res) {
console.log(res);
})
.catch(function(err){
console.log('error');
});
};
exports.handler([], null, function(){});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment