Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- 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);
- });
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement