Implement a Root-Level Request Logger Middleware - console not displaying message

This is in regard to this lesson:
https://learn.freecodecamp.org/apis-and-microservices/basic-node-and-express/implement-a-root-level-request-logger-middleware

I’ve got a solution that passes, but it’s not actually logging anything to the console. I’m unfamiliar with Glitch, but I figured out how to open the console and the logger. No messages are appearing in either of them when I have my live app page open at the root route and refresh it. That ought to be a “get” request and therefore log the console message as expected. Does anyone know what the issue here might be?

(Running the “refresh” command that the Glitch console tells you about didn’t work either.)

Here’s my code, just in case something is wrong there:

var express = require('express');
var app = express();

// --> 7)  Mount the Logger middleware here
app.use("/", function(req, res, next) {
  console.log(req.method + " " + req.path + " - " + req.ip);
  next();
});
1 Like

Try taking out the “/” and just leave the function maybe?

Actually nm. Maybe post a link to view the whole project code?

What you have works for me.

Hm, you’re right – after closing the app completely and exiting Glitch, then re-opening it, it’s working fine for me too. Maybe Glitch just had a brief… glitch.