Basic Node and Express -Use the .env File

Tell us what’s happening:

I followed the instructions but i cant still pass the test
that’s my code below

app.get(“/json”, (req, res) => {
const mySecret = process.env[‘MESSAGE_STYLE’];
if (mySecret === “uppercase”) {
res.json ({“message”: “HELLO JSON”})
} else {
res.json ({“message”: “Hello json”});
}
})
###My project link(s)

Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36

Challenge Information:

Basic Node and Express - Use the .env File

you are in good position, just a little fix you need.

first as it says use this syntax to access the env variable environment variables are accessible from the app as process.env.VAR_NAME but you are using bracket notation with quotations which is incorrect.

Next, you are not using dotenv package in your myApp.js file, to load the environment variables. how do you do that well it is written for you in the instruction

 At the top of your myApp.js file, add require('dotenv').config() 
to load the environment variables.

Thank you!

I have fixed it and passed the test.
The problem was from the MESSAGE_STYLE In mySecrete key. There was a space before the uppercase in the secrete key so i was able to solve it by closing up the space .