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

Tell us what’s happening:
I’m studying on local, and this code doesnt work. I got the output on vscode, but cant pass the challenge.

**let express = require(‘express’);
let app = express();
require(‘dotenv’).config()

app.use((req, _res, next) => {
console.log(${req.method} ${req.path} - ${req.ip})
next()
})

let viewsPath = __dirname + “/views/index.html”
let publicPath =__dirname + “/public”

console.log(“Hello World”);

app.use(“/public”, express.static(publicPath));

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

app.get('/json', (req, res) => {
    const mySecret = process.env["MESSAGE_STYLE"]
    mySecret === 'uppercase' ? 
      res.json({ "message": "HELLO JSON" }):
      res.json({ "message": "Hello json" })
  })

module.exports = app;
**

Your browser information:

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

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

Link to the challenge:

What is the public URL that you put the solution on?

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