nodejs promise then example

JavaScript
p.then(onFulfilled, onRejected);

p.then(function(value) {
   //  run
  }, function(reason) {
  // fail
});
Source

Also in JavaScript: