Created
November 9, 2015 04:29
-
-
Save YashdalfTheGray/5a4230d2bc6736f995b1 to your computer and use it in GitHub Desktop.
Chaining Promises
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
server.getUsername() | |
.then(function(result) { | |
return server.getProfile(result); | |
}).then(function(result) { | |
displayProfile(result); | |
return server.getProfilePicture(result.imageUrl); | |
}).then(function(result) { | |
udpateProfilePicture(result); | |
console.log('Data loaded'); | |
}).catch(function(error) { | |
// this catch block will run if anything | |
// breaks in the entire promise chain or | |
// if one of them is rejected. | |
console.log(error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment