Use the .env file (HELP)

Guys, I am currently stuck on this problem. I am using Replit and I am honestly having a problem passing the challenge.

I have already done research on this topic, and from what I see, my code should be working. Is there something that I am missing?

I have already created the .env file at the root of my project. I have also created the code in the app. I have tested the app and everything is fine. But when I try to submit my solution, it doesn’t work.

I am just at a loss right now.

Your project link(s)


Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

Here is the code that I have so far.

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

console.log("Hello World");
app.get("/", function(req, res){
  res.sendFile(__dirname + "/views/index.html")

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

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

This is the error message that I keep getting:

// running tests
The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE
// tests completed

it should be the one from previous challenge, Hello json

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 (’).

1 Like

Thank you for your response. I changed it from "Hello Json" to "Hello json" and still, no go. :frowning:

what’s in your .env file?

This is in my .env file:


When I submit your link, all of the tests pass.

Hey Sky020!

What did you submit?

So far, I have tried:

and neither one would work. I have no idea what I am doing wrong.

You should always only submit the base URL:

When you submit, can you see any errors in the BROWSER console? (on the /learn page)

Thank you guys!!

I am not sure what happened but after I tried to submit it for the 1000th time, it finally passed the tests.

Thank you all for your helpful responses. :smile:

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