Skip to content

Instantly share code, notes, and snippets.

@YashdalfTheGray
Created November 9, 2015 04:29
Show Gist options
  • Save YashdalfTheGray/5a4230d2bc6736f995b1 to your computer and use it in GitHub Desktop.
Save YashdalfTheGray/5a4230d2bc6736f995b1 to your computer and use it in GitHub Desktop.
Chaining Promises
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