Last active
January 18, 2016 13:32
-
-
Save dapangmao/4ac4e163ef9d51a8cf4f to your computer and use it in GitHub Desktop.
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 characters
function someAsyncThing(x) { | |
return new Promise(function(resolve, reject) { | |
// this will throw, x does not exist | |
if (x > 10) { | |
resolve(x); | |
} else { | |
reject(x); | |
} | |
}); | |
}; | |
someAsyncThing(343) | |
.then(function(res) { | |
console.log('everything is great is ', res); | |
}) | |
.catch(function(error) { | |
console.log('oh no', error); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment