Basic Node and Express .env file

I have tried about ten different solutions. All of them give me the correct json response when I view them myself but the freeCodeCamp Validation is failing.

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

app.get('/json', (req, res) => {
  var response = {"message": "Hello json"};

  if (process.env.MESSAGE_STYLE === "uppercase")
    response.message = response.message.toUpperCase();
  else
    response.message = response.message;
  res.json(response);
});

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

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

User Agent is: Mozilla/5.0 (X11; Ubuntu; Linux x86_64; rv:85.0) Gecko/20100101 Firefox/85.0.

Challenge: Use the .env File

Link to the challenge:

I think this is relevant

2 Likes

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