Use the .env file - Can't complete the challenge?

When I try to submit the challenge on this step in Basic Node and Express, I get the following message:

// running tests
The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE
// tests completed

My code does that, but the passoff isn’t accepting it for some reason. Below is the code snippet I use in the glitch app to get it to work.

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

  var response = "Hello json"
  if (process.env.MESSAGE_STYLE == "uppercase") {
    response = response.toUpperCase();
  } 
  res.json({
    message: response
  });
})

What does freecodecamp want me to put as my answer then if it won’t accept this? The logs don’t show anything abnormal. A link to the project I’m using: https://glitch.com/~caring-occipital-gull

Pretty sure it’s a bug.

Make sure you get the latest version of the fCC dependency.

"fcc-express-bground": "https://github.com/freeCodeCamp/fcc-express-bground-pkg.git"

Open your package.json and remove the package. Wait for Glitch to finish removing it (look at the Tools spinning icon and wait) then add it back and wait for the install to finish. You should now be able to complete the challenge.


Edit: You can check that you have the correct dependency by opening up the browser console (F12) and submitting it. If you get this error Error: Unexpected token < in JSON at position 0 then you do not have the latest version of the dependency.

1 Like