Basic Node and Express - Implement a Root-Level Request Logger Middleware

app.use(function middleware(req, res, next) {
  // Do something
  console.log(`${req.method} ${req.path} - ${req.ip}`)
  console.log("I'm a middleware...");
  // Call the next function in line:
  next();
});

hey can u help me

How/where are you running the code? Can we see all of it?

If it is locally use a GitHub repo to post the code, or if you have it on Replit post the link.


If you are running it locally, try updating the dependencies. We recently fixed an issue in the fcc-express-bground-pkg test dependency (related to the IP test). Running the dependency install again should do it, otherwise, you can remove the dependency and then reinstall.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.