Created
June 10, 2018 22:00
-
-
Save MostlyFocusedMike/ca3d00af347ce5c11e8557dec4babe83 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
// we'll use arrow functions for brevity | |
let asynchProm = new Promise((resolve, reject) => { | |
let fakeCode = 200; | |
window.setTimeout(() => { | |
if (fakeCode === 200) { | |
resolve({status: "OK"}) | |
} else { | |
reject({status: "ERROR"}) | |
} | |
}, 3000); | |
}); | |
asynchProm | |
.then((result) => console.log(result.status)) | |
.catch((result) => console.log(result.status)) | |
console.log("Load up your page"); | |
// LOG: Load up your page | |
** 3 seconds will pass ** | |
// LOG: OK |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment