.then javascript

JavaScript
//create a Promise
var p1 = new Promise(function(resolve, reject) {
  resolve("Success");
});

//Execute the body of the promise which call resolve
//So it execute then, inside then there's a throw
//that get capture by catch
p1.then(function(value) {
  console.log(value); // "Success!"
  throw "oh, no!";
}).catch(function(e) {
  console.log(e); // "oh, no!"
});
const promise2 = doSomething().then(successCallback, failureCallback);
const myFirstPromise = new Promise((resolve, reject) => {
  // esegue qualcosa di asincrono che eventualmente chiama:
  //
     resolve(someValue); // fulfilled
  // oppure
     reject("motivo del fallimento"); // rejected
});
Source

Also in JavaScript: