Basic Node and Express - Use the .env File

Tell us what’s happening:
Describe your issue in detail here.
Been “Spinnin’ my Wheels” on this challenge most of the day. Have tried everything “every which way but loose.” Have no idea what I’m doing wrong. Could someone please give me the right answer so I can just Move On.
Your project link(s)

solution: boilerplate-express (2) - Replit

Your browser information:

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

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

Link to the challenge:

If you are using replit for this challenge you dont use an .env file because replit doesnt use them go to the secrets tab add the variable name and the corresponding value click add then you can click a link and replit will automatically add the code into your file so you can use the variable.

I did use the secrets tab to set up my variable. Here is a copy of the latest code I’ve tried and a link to my URL.

app.get(“/json”, function(req, res) {
res.json({message: “Hello json”})
const mySecret = process.env[“MESSAGE_STYLE”]
if(mySecret == “uppercase”) {
res.json.toUpperCase();
}
});

https://replit.com/@bradleynease/boilerplate-express-2#myApp.js

This code won’t work because you send the JSON response and then have a conditional statement which effectively tries to send it again.
Also, res.json.toUpperCase() isn’t valid code, as it should take an object, not a method.

So, have a conditional statement which sends a single res.json depending on the value of the env variable. You can either explicitly send ‘HELLO JSON’ or have the message stored in a variable and use toUpperCase() within the res.json object.