You rarely build promises first — you read them. .then(handler) runs when the promise fulfills. .catch(handler) runs when it rejects. Both handlers run later, after the current call stack (same idea as Phase 10 timers).

Results appear here.

Run a lookup and watch .then or .catch fire.

Important JavaScript

lookupPlayer("Ava")
  .then(function (player) {
    console.log(player.name); // runs on success
  })
  .catch(function (error) {
    console.log(error.message); // runs on failure
  });

// .then / .catch register callbacks — they do not pause the rest of your script.