Implement a Root-Level Request Logger Middleware

Implement a Root-Level Request Logger Middleware
0.0 0

  var method=req.method;
  var path=req.path;
  var ip=req.ip;
  console.log(method+' '+path+' - '+ip);

what else should I use to complete this challenge


Same problem here, don’t know what is the passing criteria of this challenge…

// running test
root-level logger is not working as expected
// tests completed


What does the rest of your code look like? Express uses middleware in order, so that could be an issue.


Pay attention to this:

Hint: Express evaluates functions in the order they appear in the code. This is true for middleware too. If you want it to work for all the routes, it should be mounted before them. that is, place your code before the routes!


Hi, i used app.use instead of app.all and that worked


put this line

app.use(function(req, res, next){console.log(req.method + ' ' + req.path + ' - ' + req.ip); next();})

Just after you define var app = express()