From 3c0c15c1892de4cb6feac1e3a7bdcaf9746da409 Mon Sep 17 00:00:00 2001 From: Ajay Tanwar Date: Wed, 20 Mar 2019 06:44:30 +0530 Subject: [PATCH] Update index.md (#31780) --- guide/english/nodejs/express/index.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/guide/english/nodejs/express/index.md b/guide/english/nodejs/express/index.md index 281257ae87..8c11ae18c8 100644 --- a/guide/english/nodejs/express/index.md +++ b/guide/english/nodejs/express/index.md @@ -211,7 +211,7 @@ If we now start the server from command line using `node index.js` and try visit Middleware functions are those functions that have access to the request object (`req`), the response object (`res`), and the `next` function in the application’s request-response cycle. The objective of these functions is to modify request and response objects for tasks like parsing request bodies, adding response headers, make other changes to request-response cycle, end the request-response cycle and call the next middleware function. -The `next` function is a function in the Express router which is used to execute the other middleware functions succeeding the current middleware. If a middleware function does include `next()` that means the request-response cycle is ended there. The name of the function `next()` here is totally arbitary and you can name it whatever you like but is important to stick to best practices and try to follow a few conventions, especially if you are working with other developers. +The `next` function is a function in the Express router which is used to execute the other middleware functions succeeding the current middleware. It executes the next middleware function sitting in the middleware stack. If a middleware function does not include `next()` that means the request-response cycle is ended there. The name of the function `next()` here is totally arbitary and you can name it whatever you like but is important to stick to best practices and try to follow a few conventions, especially if you are working with other developers. For example , in passport strategies you will find `done()` function which is another name for the succeeding middleware. Also, when writing a custom middleware do not forget to add `next()` function to it. If you do not mention `next()` the request-response cycle will hang in middle of nowhere and you servr might cause the client to time out.