"Use the .env File " challenge has problems

i don’t know what i’m doing wrong. I’m pretty sure there are no errors.

var express = require('express');
var app = express();
const mySecret = process.env['MESSAGE_STYLE']

app.use("/public", express.static(__dirname + "/public"))


 app.get("/", (req, res) => {
  path = __dirname + "/views/index.html"
  res.sendFile(path)
});
 


app.get("/json", async function (req, res){


    let response = "hello json"
    if (mySecret === "uppercase") {

        response = response.toUpperCase();

    }

    console.log(response)
    return res.json({"message": response});
  
});

 module.exports = app;

Result in the console is:
*
hello json
*
HELLO JSON

Your project link(s)

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

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

If you check your environment variable out here in the global space, then its impossible for your app to respond to changes in this env variable.

1 Like