Implement a Root-Level Request Logger Middlewar

**Tell us what’s happening
I attempted to submit my link but it not going through. Also in the console, its saying that let is not defined .

var express = require(‘express’);

var app = express();

let absolutePath = __dirname + “/views/index.html”;

app.use(express.static(__dirname + “/public”));

app.use((req,res,next) => {

let (method, path, ip) = req;

console.log(method +" " + path + " " + ip)

next();

})

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

// res.send(“Hello Express”)

// })

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

res.sendFile(absolutePath)

})

app.get("/json", (req, res) => {

res.json({“message”: process.env.MESSAGE_STYLE == “uppercase” ? “HELLO JSON”: “Hello json”})

})

console.log(“Hello World”);

Your project link(s)

solution: https://replit.com/@brandondorsey/boilerplate-express

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

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