Use the .env file | nothing seems to be working

Tell us what’s happening:
I’ve been trying to solve this problem for the past 2 hours to no avail. I’ve tried searching up videos that explain the problem, nothing.

Your code so far

var express = require('express');
var app = express();
const mySecret = process.env['MESSAGE_STYLE']

app.get("/", function(req, res) {
  res.sendFile(__dirname + "/views/index.html");
app.use("/public", express.static(__dirname + "/public"))

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

and yes, I have created a .env file, with the correct naming requirements.

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

The response object should either be {"message": "Hello json"} or {"message": "HELLO JSON"}

What you have here does not quite match up for the lowercase response

1 Like

thanks a lot! turns out that was the error lol

Could you help me please. Below is my code followed by the error message…

app.get("/json", function(req, res) {
var response = “Hello json”;
if (mySecret === “uppercase”) {
response = response.toUpperCase();
res.json({ “message”: response });

// running tests The response of the endpoint


should change according to the environment variable


// tests completed

You should create a new question. Not many people will see your question here as a comment to someone else’s question. Plus the the moderators can help you with formatting your question.