Complete the code to apply middleware that logs requests before reaching the handler.
app.use([1]);The middleware function loggerMiddleware processes requests before handlers to log details.
Complete the middleware function to call the next handler in the chain.
function logger(req, res, [1]) { console.log('Request received'); [1](); }
The next function passes control to the next middleware or handler.
Fix the error in the middleware to ensure it processes requests before handlers.
function authMiddleware(req, res, next) {
if (!req.user) {
res.status(401).send('Unauthorized');
} else {
[1]();
}
}Calling next() passes control to the next middleware or handler after authentication check.
Fill both blanks to create middleware that modifies request data before handler.
function modifyMiddleware(req, res, [1]) { req.customData = 'data'; [2](); }
The next function is used both as parameter and called to continue processing.
Fill all three blanks to create middleware that logs, modifies, and passes request to handler.
function combinedMiddleware(req, res, [1]) { console.log('Start'); req.modified = true; [2](); console.log([3]); }
The middleware uses next to continue and logs 'End' after calling it.