Basic Node and Express - Use the .env File

Tell us what’s happening:

My code can’t seem to pass the test case. Even though the correct output is being shown at the ‘/json’ endpoint. Any help?

This the code:

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

mySecret = process.env.MESSAGE_STYLE

if( process.env.MESSAGE_STYLE == “uppercase”){
message = “Hello Json”.toUpperCase();
res.json({message})
}
else if( process.env.MESSAGE_STYLE != “uppercase”){
message = “Hello json”;
res.json({message})

}
})

This is my variable in the Secrets tab

image

Your project link(s)

https://boilerplate-express.k191378.repl.co/json

Your browser information:

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

Challenge: Basic Node and Express - Use the .env File

Link to the challenge:

Your solution is correct, but you submitted the wrong URL to FCC. You should submit the base URL, without /json at the end, like this:

https://boilerplate-express.k191378.repl.co

If you submit https://boilerplate-express.k191378.repl.co/json, then it will try to connect to https://boilerplate-express.k191378.repl.co/json/json, which does not exist.

You can keep that in mind for future challenges on replit – always submit the base URL of your project.

You were right, i submitted the base URL and it worked! Thanks a lot :slight_smile:

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