why we are calling next function in middleware?
Doubt at 1 hour 5 min 20 sec
@arpit5028 what next does is that, it passes the control onto next middleware function, to do following tasks:
Execute any code. Make changes to the request and the response objects.
if it use to paas the control to middleware function what is the use of next function in server.get()
sir if we send a response from use() then why we are using get()
get is a middleware to, next is needed to pass the control onto the next function if there is any in the response cycle
get() is called when HTTP method is set to GET, use() will be called regardless of the HTTP method, so say you have some task you want to do before performing operation on any request then use it in use(), or if there is any specific task related to GET, POST, PATCH, DELETE use specific methods
I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.
On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.