Skip to content

Instantly share code, notes, and snippets.

@oreillyross
Created January 21, 2016 14:15
Show Gist options
  • Save oreillyross/19b25567653deeb8f8be to your computer and use it in GitHub Desktop.
Save oreillyross/19b25567653deeb8f8be to your computer and use it in GitHub Desktop.
let myPromise = new Promise((resolve,reject) => {
if( /* something is */ true ) {
resolve('Everything worked');
}
else {
reject('Something went wrong');
}
});
myPromise.then(resolved => {
//fulfilled
console.log(resolved)},
//rejected
rejected => {
//Will only be called if it is rejected
console.log(rejected)
}
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment