Created
April 29, 2017 19:03
-
-
Save Nahiduzzaman/fb19759409c54d683266084c12c3cda4 to your computer and use it in GitHub Desktop.
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
let myFirstPromise = new Promise((resolve, reject) => { | |
// We call resolve(...) when what we were doing async succeeded, and reject(...) when it failed. | |
// In this example, we use setTimeout(...) to simulate async code. | |
// In reality, you will probably be using something like XHR or an HTML5 API. | |
setTimeout(function(){ | |
resolve("Good To go"); // Yay! Everything went well! | |
}, 1000); | |
}); | |
myFirstPromise.then((response) => { | |
// successMessage is whatever we passed in the resolve(...) function above. | |
// It doesn't have to be a string, but if it is only a succeed message, it probably will be. | |
console.log(response); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment