Code works but FCC won't accept

Tell us what’s happening:

Your project link(s)

I have a variable in the .env file called MESSAGE_STYLE as well

solution: 
app.js file
var response

if (process.env.MESSAGE_STYLE=== "uppercase") {
  response = "HELLO JSON"
} else {
  response = "Hello json";
}

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

I am getting the correct output as well

Hello there,

Would you mind sharing a link to your project code as well please? It is difficult to see what is going on without being able to see your full code.

Sorry, here: Glitch :・゚✧

Here is the issue:


if (process.env.MESSAGE_STYLE=== "uppercase") {
  response = "HELLO JSON"
} else {
  response = "Hello json";
}

app.get("/json", (req, res) => {
  res.json({
    message: response
  });
});

I walked through the issue here: Node and Express Json response Error - JavaScript - The freeCodeCamp Forum

Hope this helps

1 Like

Thanks a lot, I figured it out.

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