Promise objects can be in one of three states:
- Pending: This is the initial state, neither fulfilled nor rejected
- Fulfilled: This is the final state where it executed successfully and produced a result
- Rejected: This is the final state where execution failed
Consider this code segment similar to the one we'll use later in this chapter:
notes.read(req.query.key) .then(note => { return filterNote(note); }) .then(note => { return swedishChefSpeak(note); }) .then(note => { res.render('noteview', { title: note ? note.title : "", notekey: req.query.key, note: note }); }) .catch(err => { next(err); });
There are several places where errors can occur in this little bit of code. The notes.read function has several possible ...