Use the env file

Do I put the entire if statement in one bracket? I can’t think of anything else to make this work.

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

I am not sure what you mean. There are many ways to accomplish this challenge. What does your code look like?

https://replit.com/@Bl1xvan/boilerplate-express-1#myApp.js

Like this

app.get("/json", (req, res)=>{
  res.json(if(procss.env.MESSAGE_STYLE === 'uppercase')              {"message": "Hello json"}
            else{
                "message": "Hello json" 
                }
              )
            }
          )

I tried to post the link but it disappears

If statements do not have return values. I would invoke res.json inside of the if statement branches.

app.get("/json", (req, res)=>{
  if(process.env.MESSAGE_STYLE === "uppercase")      {res.json({"message": "Hello json"}).toUpperCase()}else{
   res.json({"message": "Hello json"}) 
  }
  })

Like this?

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

toUpperCase() is a method on strings, not on res.json()

let express = require('express');
let app = express();

console.log("Hello World")

app.get("/", (req, res)=>{
  res.sendFile(__dirname + "/views/index.html")
})

app.use("/public", express.static(__dirname + "/public"))

app.get("/json", (req, res)=>{
  if(process.env.MESSAGE_STYLE === "uppercase")      
  {
    res.json({"message": "HELLO JSON"})
    }else{
     res.json({"message": "Hello json"}) 
    }
  }
)

I tried just capitalizing “Hello json” manually, but even that didn’t work