Skip to content

Instantly share code, notes, and snippets.

@a1exlism
Created February 25, 2018 09:54
Show Gist options
  • Select an option

  • Save a1exlism/14190b7c5609afde755ab0ab4c0db951 to your computer and use it in GitHub Desktop.

Select an option

Save a1exlism/14190b7c5609afde755ab0ab4c0db951 to your computer and use it in GitHub Desktop.
function asyncFunction() {
return new Promise(function(resolve, reject) {
console.log('Async Hellow World');
resolve('X');
});
}
asyncFunction().then(function (data) {
console.log('Your request was approved, and the variable is ' + data);
}, function(data) {
console.log('The server reject your request');
}).catch(function(err) {
console.log('Error: ' + err);
});
/*
* Main Func: success | resolve ; fail | reject == user defined ???
* Callback: success | then ; fail | catch
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment