I’ve been stuck on this one for a bit now, I’ve gone over previous forum posts and tried all suggestions. Still, the test “Root level logger middleware should be active” fails. As far as I can see, the console outputs what it’s supposed to. I have tried resetting the project, commenting out code from earlier challenges, and rewriting the code to match code from supposedly working forum solutions.
My code:
var express = require('express');
var app = express();
app.use(function middleware(req, res, next) {
console.log(`${req.method} ${req.path} - ${req.ip}`)
next();
});
console.log("Hello World");
app.get("/", function(req, res) {
res.sendFile(__dirname + "/views/index.html");
})
app.use(express.static(__dirname + "/public"));
app.get("/json", function(req, res) {
if (process.env.MESSAGE_STYLE === "uppercase") {
res.json({ "message": "HELLO JSON" });
} else {
res.json({ "message": "Hello json" });
}
})
My repl.it:
https://repl.it/@oddgrd/boilerplate-express-5#myApp.js
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:85.0) Gecko/20100101 Firefox/85.0
.
Challenge: Implement a Root-Level Request Logger Middleware
Link to the challenge: