Created
April 29, 2017 19:03
-
-
Save Nahiduzzaman/fb19759409c54d683266084c12c3cda4 to your computer and use it in GitHub Desktop.
Revisions
-
Nahiduzzaman created this gist
Apr 29, 2017 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,14 @@ 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); });