Having trouble with an exercise

Tell us what’s happening:
I am in the Basic Node and Express - Use the .env file. The hint did not help me. Can you please assist further?

Your code so far

/** 6) Use the .env file to configure the app */
if (process.env.MESSAGE_STYLE === "allCaps") {
  response = "Hello json".toUpperCase();
} else {
  response = "Hello json";

Your browser information:
Google chrome

Challenge: Use the .env File

Link to the challenge:

this is how my code looks like now:

/** 6) Use the .env file to configure the app */
//var response = "Hello World".toUpperCase();
app.get("/json", (req,res)=>{
   if (process.env.MESSAGE_STYLE === "allCaps") {
     res.json({message: "Hello json".toUpperCase()});
   } else 
     res.json({message: "Hello json"});

I am getting this message for my answer: The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE

Where am i going wrong? Please advise!

Please post the link to your Glitch project.

Not sure if the test actually cares or not but you are asked to use MESSAGE_STYLE=uppercase not MESSAGE_STYLE=allCaps.


here's the link to my project: https://iridescent-gray-lunch.glitch.me

You have two /json get routes, only the first will match so the second never runs. Also, I don’t see the .env file in your project?

thanks for your suggestions. i had assumed the .env file already existed, but i guess it didn’t, so i created it and added the variable MESSAGE_STYLE with the value “uppercase” to it. Then i commented out the solution for challenge #5. Then checked the output at the URL (my project’s path/json). Finally, it worked, thank you.