Created
February 19, 2019 00:29
-
-
Save alejandrolechuga/3c4793b64cf3c6bd661836a55bc32fe7 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
function random(){ | |
return Math.floor(Math.random() * 10); | |
} | |
function getJSON() { | |
return new Promise(function (resolve, reject) { | |
setTimeout(() => resolve('Yes'),random()); | |
setTimeout(() => reject('No'), random()); | |
}); | |
} | |
var promise = getJSON() | |
.then((data) => { | |
console.log(data); | |
}).catch((data) => { | |
console.log(data); | |
}); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment