Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Javascript Promises
let example = new Promise(
function(resolve, reject){
let success = do some async task;
if(success){
resolve();
}else{
reject();
}
};
);
example.then(
success => //do something with success value, //note: this is the function passed for resolve()
error => //do something with error //note: this is the function passed for reject()
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment