Last active
January 24, 2017 00:03
-
-
Save juniorb2ss/c1e98dd5cf5d09321e72fdf1bc211978 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
'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