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

Root level logger middleware should be active*
I’ve been at this for over an hour and I’m still not able to pass my code this is what i have

let express = require(‘express’);
let app = express();
app.use((req, _res, next) => {
console.log(${req.method} ${req.path} '-' ${req.ip});


app.use(/public, express.static(${__dirname}/public));

app.get(“/”, (req, res)=>{

app.get(/json, (req, res)=> {
let greeting = ‘Hello json’;

if(process.env.MESSAGE_STYLE === 'uppercase') {
    greeting = greeting.toUpperCase();
res.json({message: greeting});


module.exports = app;

solution: http://localhost:3000

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

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

Link to the challenge:

  • share that “repl” link that you might have for this as well

happy learning :slight_smile:

There is an issue with IPv6 that might be causing this to fail on localhost. Try adding this to the server.js file at the top with the rest of the require statements.

const dns = require('dns');

This should hopefully be fixed soon™

1 Like

Thanks a heap mate! This fixed my issue as well. Code was completely fine but FCC servers kept failing the submission.
Yours is the first post I’ve seen that solves this issue.

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