# Use the .env file (HELP)

**URL:** <https://forum.freecodecamp.org/t/use-the-env-file-help/455674>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [April 13, 2021, 1:36pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674 "2021-04-13T13:36:34Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![shly.ashley](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shly.ashley/32/187376_2.png) [@shly.ashley](https://forum.freecodecamp.org/u/shly.ashley)\
**Post date:** [April 13, 2021, 1:36pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/1 "2021-04-13T13:36:35Z")

</div>

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)**

solution: [https://boilerplate-express.xoshly.repl.co](https://boilerplate-express.xoshly.repl.co)

**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:**

> **[freeCodeCamp.org](https://www.freecodecamp.org/learn/back-end-development-and-apis/basic-node-and-express/use-the--env-file)**
>
> Learn to Code — For Free

---

<div class="post-metadata">

**Author:** ![shly.ashley](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shly.ashley/32/187376_2.png) [@shly.ashley](https://forum.freecodecamp.org/u/shly.ashley)\
**Post date:** [April 13, 2021, 1:38pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/2 "2021-04-13T13:38:52Z")

</div>

Here is the code that I have so far.

```auto
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"});
});

```

---

<div class="post-metadata">

**Author:** ![shly.ashley](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shly.ashley/32/187376_2.png) [@shly.ashley](https://forum.freecodecamp.org/u/shly.ashley)\
**Post date:** [April 13, 2021, 1:47pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/3 "2021-04-13T13:47:59Z")

</div>

This is the error message that I keep getting:

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

```

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [April 13, 2021, 1:48pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/4 "2021-04-13T13:48:52Z")

</div>

> [@shly.ashley](#):
>
> res.json({“message”: “Hello Json”})

it should be the one from previous challenge, `Hello json`

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [April 13, 2021, 1:49pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/5 "2021-04-13T13:49:23Z")

</div>

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.

 ![Pre-formatted-text](https://global.discourse-cdn.com/freecodecamp/original/3X/1/b/1b18854f1059217f29370444396145cc3a0cd8ae.gif)

See [this post](https://forum.freecodecamp.org/t/forum-code-formatting/25574) to find the backtick on your keyboard.  
**Note:** Backticks (`) are not single quotes (’).

---

<div class="post-metadata">

**Author:** ![shly.ashley](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shly.ashley/32/187376_2.png) [@shly.ashley](https://forum.freecodecamp.org/u/shly.ashley)\
**Post date:** [April 13, 2021, 1:54pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/6 "2021-04-13T13:54:42Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ILM](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/ilm/32/363239_2.png) [@ILM](https://forum.freecodecamp.org/u/ILM)\
**Post date:** [April 13, 2021, 2:16pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/7 "2021-04-13T14:16:17Z")

</div>

what’s in your `.env` file?

---

<div class="post-metadata">

**Author:** ![shly.ashley](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shly.ashley/32/187376_2.png) [@shly.ashley](https://forum.freecodecamp.org/u/shly.ashley)\
**Post date:** [April 13, 2021, 2:28pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/9 "2021-04-13T14:28:53Z")

</div>

This is in my `.env` file:

```auto
MESSAGE_STYLE=uppercase

```

---

<div class="post-metadata">

**Author:** ![Sky020](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sky020/32/128093_2.png) [@Sky020](https://forum.freecodecamp.org/u/Sky020)\
**Post date:** [April 13, 2021, 2:28pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/10 "2021-04-13T14:28:53Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![shly.ashley](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shly.ashley/32/187376_2.png) [@shly.ashley](https://forum.freecodecamp.org/u/shly.ashley)\
**Post date:** [April 13, 2021, 2:31pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/11 "2021-04-13T14:31:19Z")

</div>

Hey Sky020!

What did you submit?

So far, I have tried:  
[https://boilerplate-express.xoshly.repl.co](https://boilerplate-express.xoshly.repl.co)  
[https://boilerplate-express.xoshly.repl.co/](https://boilerplate-express.xoshly.repl.co/)  
[https://boilerplate-express.xoshly.repl.co/json](https://boilerplate-express.xoshly.repl.co/json)

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

---

<div class="post-metadata">

**Author:** ![Sky020](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/sky020/32/128093_2.png) [@Sky020](https://forum.freecodecamp.org/u/Sky020)\
**Post date:** [April 13, 2021, 2:32pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/12 "2021-04-13T14:32:25Z")

</div>

You should always only submit the base URL:  
`https://boilerplate-express.xoshly.repl.co/`

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

---

<div class="post-metadata">

**Author:** ![shly.ashley](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/shly.ashley/32/187376_2.png) [@shly.ashley](https://forum.freecodecamp.org/u/shly.ashley)\
**Post date:** [April 13, 2021, 2:34pm UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/13 "2021-04-13T14:34:59Z")

</div>

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. 😄

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/freecodecamp/original/3X/e/1/e1c433102e34b46dfaa3e15d13ab9a514b127078.svg) [@system](https://forum.freecodecamp.org/u/system)\
**Post date:** [October 13, 2021, 2:35am UTC](https://forum.freecodecamp.org/t/use-the-env-file-help/455674/14 "2021-10-13T02:35:56Z")

</div>

Closed on October 13, 2021, 2:35am UTC

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