Skip to content

Instantly share code, notes, and snippets.

@jpina
Created November 25, 2015 11:03
Show Gist options
  • Save jpina/254892be7a4f89f771a2 to your computer and use it in GitHub Desktop.
Save jpina/254892be7a4f89f771a2 to your computer and use it in GitHub Desktop.
04 Chaining
var promise = new Promise(function(resolve, reject) {
resolve(1);
});
promise.then(function(val) {
console.log(val); // 1
return val + 2;
}).then(function(val) {
console.log(val); // 3
});
get('story.json').then(function(response) {
return JSON.parse(response);
}).then(function(response) {
console.log("Yey JSON!", response);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment