Last active
January 24, 2017 00:03
-
-
Save juniorb2ss/c1e98dd5cf5d09321e72fdf1bc211978 to your computer and use it in GitHub Desktop.
Revisions
-
juniorb2ss revised this gist
Jan 24, 2017 . 1 changed file with 4 additions and 5 deletions.There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -1,4 +1,3 @@ 'use strict'; var Promise = require('bluebird'); @@ -10,14 +9,14 @@ if (typeof Promise === 'undefined') { } 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'; } -
juniorb2ss created this gist
Jan 23, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,33 @@ '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(options){ return new Promise(function(resolve,reject){ setTimeout(function(){ resolve('getUserAsync Function')}, 3000); }); }); function getUser(event, context, callback){ 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(){});