Promise in Javascript

let promiseToFixSomething = new Promise(function(resolve, reject) {
  //Learning
  let isFixed = false;

  if (isFixed ) {
    resolve('Fixed!!');
  } else {
    reject('Nah');
  }
});

promiseToFixSomething.then(function(fromResolve) {
    console.log('Fixed?' + fromResolve);
  }).catch(function(fromReject){
    console.log('Fixed?' + fromReject);
});

Comments

Popular posts from this blog

Interview Question on Ruby on Rails

Inserting and Moving elements inside Ruby Array