Skip to content

Lesson 06 Task Manager API Part 2 of 2

John R. McGarvey edited this page Apr 12, 2024 · 2 revisions

Lesson Page

Lesson 6 is a continuation of lesson 5, but there is a lot of emphasis first on validation of the schema of entries via the model, and then on how to do custom error handling. Error handling middleware should be emphasized as this is a key part of the lesson. I expect there will be plenty of questions about the flow, and students may have specific issues in getting their code running.

Note to reviewers: Expect to find a file QuizAnswers2.txt with answers to open-ended questions. Look at the lesson page for details. Here are sample answers:

  1. When one makes an async call to the database, in this case MongoDB, that call may fail and throw an exception. This may happen if the database is not responding or the network isn't working, but it can also happen because there are errors in the call to MongoDB, such as an attempt to store a record that doesn't comply with the schema. There must be an error handler to catch the exception and to report meaningful results to the user in these cases.
  2. The "your code here" should have something like:
res.status(404).json(message: "That task was not found.");

Clone this wiki locally