a1exlism
2/25/2018 - 9:54 AM

promise_base

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
 */