I need help on writing this closure function. Can you please explain the closure use case in here in more detail? I think I don't understand closure conceptually, even after going through the "Advanced Functions" chapter again.
Here is the error I am getting:
My middleware.js file:
export const logger = (req, res) => {
return (next) => {
next();
}
}
My server.js file:
import express from 'express';
import {logger} from './middleware.js'
const server = express();
server.get('/', (req, res) => {
res.send('Learning to use middleware!');
});
server.get('/about', (req, res) => {
res.send(`I'm going to become a JS Developer in ${new Date().getFullYear()}!`);
});
server.use(logger);
export { server };