Scott goes through the solution to exercise 3.
- For app.param again, this is going to...…First we actually register app.param…before we register these routes.…Which is great.…That's adding it to the stack earlier.…If we put this below the routes,…then it wouldn't work regardless.…So we add it before the routes.…And then we have…it's looking for the parameter of the name of ID.…And then it passed our value…as a fourth argument here right?…And then what we do is we just do what we did before,…we just find the line with that ID.…
If it's a lion, attach it to req.lion, then call next.…If not then just, nothing.…Just send back to the client like,…"Uhh, that's not a real ID."…You set the status code to something else but, yeah.…Just respond back to the client, don't even go next.…The next one was create an error handler.…This is actually wrong 'cause it needs to be down here.…
Boom.…So error handler is just like we did last time.…It's a middleware function that takes in that require…for arguments with the error as the first one…and then just sends back an error here.…
This course was created by Frontend Masters. It was originally released on 12/30/2015. We're pleased to host this training in our library.
- Executing Node.js
- Using Express
- What is middleware?
- Testing in Node.js
- Using Mongo with Node.js
- Data modeling
- Querying data with Mongoose
- Identifying sensitive routes
- Configuring the deployment
Skill Level Intermediate
Node.js: Build Your First Microservicewith Daniel Khan2h 9m Intermediate
Building APIs Using Hapi in Node.jswith Kirsten Hunter2h 23m Intermediate
Node.js: Extend and Maintain Applicationswith Daniel Khan3h 35m Intermediate
2. REST APIs
5. Organization and Configuration
7. Data Modeling
10. Securing Routes
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.