Basic Node and Express - Use the .env File

Tell us what’s happening:

I am unable to continue with my test even though i put the correct code.

###Your project link(s)

solution: app.get(“/json”, function(req,res) {
if (process.env.MESSAGE_STYLE === “uppercase”){
res.json({
message: “Hello json”.toUpperCase()
})
} else {
res.json({
message: “Hello json”
})
}
})

Your browser information:

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

Challenge Information:

Basic Node and Express - Use the .env File

Have you setup the dotenv package as per the instructions on the page?

1 Like

I fixed the issue by adding this to the top of the page “require(‘dotenv’).config()”
this wasnt apart of the instructions but after adding that it worked, I think it needs to be added to the page.

1 Like

It is part of the instructions but you have to read to the end to find it.

1 Like