View on GitHub

reading-notes

Learning Notes Repo for Code Fellows

Express REST API

  1. Name 3 real world use cases where you’d want to change the request with custom middleware
    • printing a message
    • trigger an error handler
    • request timestamp
  2. True or false: The route handler is middleware?

    • false, a middleware function requires next argument to proceed to next
  3. In what ways can a middleware function end the process and send data to the browser?

    • response.end()
    • response.status(number).send('message')
  4. At what point in the request lifecycle can you “inject” middleware?

    • after HTTP method and before the Path
  5. What can cause express to error with “Request headers sent twice, cannot start a second response”

    • callback has been called twice
    • another function trying to set a header or status code

Terms

<==Back