Created
November 9, 2015 03:38
-
-
Save YashdalfTheGray/faa15c50520f17b4aa24 to your computer and use it in GitHub Desktop.
Promise API
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.getData(url) | |
.then(function(result) { | |
// this code block runs when the | |
// promise gets fulfilled. | |
ctrl.myData = result; | |
}) | |
.catch(function(error) { | |
// this code block runs when there | |
// is an error encountered or if the | |
// promise was rejected. | |
console.log('Something went wrong'); | |
console.log(error); | |
}) | |
.finally(function() { | |
// this code block runs in all cases | |
// and can be helpful to run clean up | |
// type tasks. | |
server.closeConnection(); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment