express-hello-world Flashcards

1
Q

How do you mount a middleware with an Express application?

A

Bind application-level middleware to an instance of the app object by using the app.use() and app.Method() functions, where METHOD is the HTTP method of the request that the middleware function handles (such as GET, PUT, or POST) in lowercase.

  • app.use(function(req, res)
  • Middleware is a function used to handle requests in an express application
  • Receives: request object(info related to request), response object(gives you information and methods relate to setting up the response), next function(allows you to call the next middleware in the stack.)
  • When you call the use method and pass a function, that is mounting it.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Which objects does an Express application pass to your middleware to manage the request/response lifecycle of the server?

A

Request and respond object and next functional (optional)…

How well did you know this?
1
Not at all
2
3
4
5
Perfectly