Skip to content

Instantly share code, notes, and snippets.

@darrellpratt
Created May 25, 2016 17:10
Show Gist options
  • Save darrellpratt/b91327e061c9f9ee6a8230d5277af86f to your computer and use it in GitHub Desktop.
Save darrellpratt/b91327e061c9f9ee6a8230d5277af86f to your computer and use it in GitHub Desktop.
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