then and catch
Consume a promise: .then for success, .catch for failure.
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.
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.