Class 3 Reading: Express REST API
Resources
ES6 Classes
- Classes are templates for creating _____.
- Can a class declaration be hoisted?
- No, class declarations are not hoisted.
- How would you describe a constructor and contextual “this” to a non-technical friend?
- A constructor is a function that is used to create an object. The “this” keyword refers to the object that is being created. It’s elementary, Watson.
Using Express Routing
- Within Express, what does routing refer to?
- Routing refers to determining how an application responds to a client request to a particular endpoint, which is a URI (or path) and a specific HTTP request method (GET, POST, and so on).
- What is the difference between a route path and a route method?
- A route path is a string that represents a URL path, and a route method is an HTTP request method.
- When is it appropriate to add
next
as a parameter to a route handler and what must you do if next
has been passed to your middleware as a parameter?
- It is appropriate to add
next
as a parameter to a route handler when you want to pass control to the next middleware function in the stack. If next
has been passed to your middleware as a parameter, you must call next()
to pass control to the next middleware function.
Express Routing
- What is an Express Router?
- An Express Router is a way to modularize your routes into separate files to keep your code clean and organized.
- By what means do we initialize
express.Router()
in an express server?
- We initialize
express.Router()
in an express server by using app.use()
.
- What do we use route middleware for?
- We use route middleware for things like logging, validation, and handling errors.
Reflection
- What are your learning goals after reading and reviewing the class README?
- My learning goals after reading and reviewing the class README are to understand how to use Express to create a REST API and to understand how to use Express middleware.
Things I Want to Know More About