Basic Node and Express - Use the .env File

freecodecamp is not accepting solution even though in my browser the response is correct here is my code :-

let express = require(‘express’);
let app = express();

require(“dotenv”).config();
app.use(“/public”, express.static(__dirname + “/public”));

app.get(“/json”, (req, res) => {
let response = “Hello json”;
if(process.env.MESSAGE_STYLE===“uppercase”){
res.json({ message: response.toUpperCase() });

} else {
res.json({ message: response });
}
});
module.exports = app;

solution: http://localhost:3000/json

Your browser information:

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

Challenge: Basic Node and Express - Use the .env File

Link to the challenge:

so the tests will check http://localhost:3000/json/json

give the link to the whole app, not the specific route

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