Created
May 25, 2016 17:10
-
-
Save darrellpratt/b91327e061c9f9ee6a8230d5277af86f 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
var rest = require('rest'); | |
fetchRemoteGreeting() | |
.then(addExclamation) | |
.catch(handleError) | |
.done(function(greeting) { | |
console.log(greeting); | |
}); | |
function fetchRemoteGreeting() { | |
// returns a when.js promise for 'hello world' | |
return rest('http://example.com/greeting'); | |
} | |
function addExclamation(greeting) { | |
return greeting + '!!!!' | |
} | |
function handleError(e) { | |
return 'drat!'; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment