Implement a Root-Level Request Logger Middle

this is my code, I could not pass the challenge even if everything is ok…
I got the message done in the console as required but didn’t pass.

** 7) Root-level Middleware - A logger */
//  place it before all the routes !
app.use(function middleware(req, res, next){
var string = req.method + ' ' +req.path +' - ' + req.ip;
//res.json(string);
console.log(string);
next();
});

No One can answer my question ? :roll_eyes::roll_eyes::roll_eyes:

I think that you should do also a challenge 6) Use the .env file to configure the app

1 Like

Moving it to the top below the comment // --> 7) Mount the Logger middleware here.

Or define the logger function at the comment /** 7) Root-level Middleware - A logger */ and mount it (app.use(functionName)) up top.

1 Like

I have just used arrow functions instead , and every thing worked just fine.