Basic Node and Express - Use the .env File

Tell us what’s happening:
Describe your issue in detail here.

**I am having issue with the .env and I have tried as much as I can
at this point, any help will go a long way

below is my code screenshoot

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


solution: boilerplate-express - Node.js Repl - Replit

Your browser information:

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

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

Link to the challenge:

It looks like you’re returning the same message no matter what

so what should I do to the code to start running I am out of solution at this point.
please a straight solution will give me more insight on what to do
Thank you

We don’t write the solution for you.

Did you try returning a different message like the instructions ask?

yes the error message is, ‘not found’

I don’t understand what you mean.

transform the response object’s message to uppercase if the variable equals uppercase . The response object should either be {"message": "Hello json"} or {"message": "HELLO JSON"} , depending on the MESSAGE_STYLE value.

You aren’t using the required messages.

You are also putting a get handler inside of a get handler. You didn’t do that on previous steps.

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

this is how my code currently look like

This message is not uppercase.

Also, you aren’t returning a message at all when the environment variable is not “uppercase”

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