Skip to the content.

Express REST API

1- Name 3 real world use cases where you’d want to change the request with custom middleware

Adding query params

Make changes to the request and the response objects.

Handling error

2- True or false: The route handler is middleware?

False 3- In what ways can a middleware function end the process and send data to the browser?

middleware functions that return a Promise will call next(value) when they reject or throw an error, next will be called with either the rejected value or the thrown Error.

4- At what point in the request lifecycle can you “inject” middleware?

after the route and befor the route handler

5- What can cause express to error with “Request headers sent twice, cannot start a second response”

when you send more than one request to the server and make interupt between this requests, the server will dell with this requests by send a response have an error.