.env File validation error

Tell us what’s happening:

I’ve seen the validation error come up a few times, it’s the same case here. I am returning the right thing I believe, would love some help. Thank you so much.
*I’ve tried both “Hello json” and “hello json” as well as moving the location of the variable ‘response’, and not using a variable, instead using a hardcoded String.

Your code so far
var express = require(“express”);
var app = express();
console.log(“Hello World”);
console.log(process.env.MESSAGE_STYLE);
var response = “Hello json”;

app.get("/", (req, res) => res.sendFile(__dirname + “/views/index.html”));
app.get("/json", (req, res) => {
if (process.env.MESSAGE_STYLE === “uppercase”) {
response = “Hello json”.toUpperCase();
}
res.json({ message: response });
});
app.use(express.static(__dirname + “/public”));

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36.

Challenge: undefined

Link to the challenge:
https://www.freecodecamp.org/learn/apis-and-microservices/basic-node-and-express/use-the-.env-file

@Sabathrodriguez Can you post a link to your Glitch project?

Also, can you post a screenshot of your .env file contents?

Thank you.

Of course!

Live App: https://spiky-globe.glitch.me

Code: https://glitch.com/edit/#!/spiky-globe

You seem to misunderstand how .env files work. I suggest reading the challenge description again. It gives an example of how variables are to be written.

You have created a JSON formatted file.

1 Like

Sounds good, Thanks!