adspace


How can you use middleware in node js?

Answer Posted / Ranjna Jaiswal

Middleware are functions that have access to the request object (req), the response object (res), and the next middleware function in the application’s request-response cycle. To use middleware, you need to add them to your Express application using the app.use() method.n```javascriptnconst express = require('express');nconst app = express();napp.use(function (req, res, next) {n // your code heren next();n});n```

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Is node js losing popularity?

592


How we can read a file in node js?

572