Issue with "Use the .env File" challenge

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

When I submit the solution to the “Use the .env File” challenge it says:

The response of the endpoint
/json should change according to the environment variable

And it is also giving an error in the console:

Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client

Your code so far

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

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101 Firefox/102.0

Challenge: Use the .env File

Link to the challenge:

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