Promise: Then & Catch Example

by Jacob King

JavaScript

myPromise
  .then(function(result) {
    console.log(result);  // Output: The operation was successful!
  })
  .catch(function(error) {
    console.log(error);   // This won’t run in this case
  });