Basic Node and Express - Use the .env File

Tell us what’s happening: The test doesn’t pass
I’m not sure what’s the problem with the code? I created Secret and inserted the variable inside the route handler
[(https://boilerplate-express.bojanaspink.repl.co)]

solution: boilerplate-express - Replit

Your browser information:

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

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

Link to the challenge:

app.get("/json", (req, res) => {
  res.json(const mySecret = process.env['MESSAGE_STYLE'] == "uppercase" ? {"message":"HELLO JSON"} : {"message":"Hello json"})
});

You can’t define a const inside a res.json. You can have the conditional statement inside there if you wish, though I’d rather put it before personally.

1 Like

You’re right! Thank you for your help!

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