Promise

node v5.12.0
version: 1.0.0
endpointsharetweet
'use strict'; const randomPuppy = require('random-puppy'); const captionBot = require('captionbot'); const whatDog = require('what-dog'); const loudRejection = require('loud-rejection'); loudRejection(); function promiseExample () { return randomPuppy().then(function(imageUrl){ return Promise.all([ imageUrl, captionBot(imageUrl), whatDog(imageUrl) ]); }).then(function(arrayOfResults){ return { imageUrl: arrayOfResults[0], caption: arrayOfResults[1], breed: arrayOfResults[2].breed, about: arrayOfResults[2].about }; }); } promiseExample().then(function(results){ console.log(results); }).catch(function(err){ console.log(err.message, err.stack); }); exports.tonicEndpoint = promiseExample;
Loading…

no comments

    sign in to comment