# I need need help with full code the env. File on replit

**URL:** <https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [November 29, 2021, 2:17am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980 "2021-11-29T02:17:05Z")\
**Posts on this page:** 13\
**Page:** 2

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [November 29, 2021, 2:59am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/22 "2021-11-29T02:59:41Z")

</div>

> [@JeremyLT](#):
>
> Do you know what part of the instructions I quoted above tells you what message to use?
> 
> Do you know what part of the instructions I quoted above tells you what the environment variable value you need to check for?

Please actually interact with me. We will not just write the answer for you.

---

<div class="post-metadata">

**Author:** ![Elisart](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/elisart/32/134110_2.png) [@Elisart](https://forum.freecodecamp.org/u/Elisart)\
**Post date:** [November 29, 2021, 3:02am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/23 "2021-11-29T03:02:51Z")

</div>

I tried and it is not working. I have been more than a week working and searching about this.

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [November 29, 2021, 3:05am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/24 "2021-11-29T03:05:22Z")

</div>

I can’t help you if you don’t actually interact with me.

Please answer these two simple questions:

1. What is the message that you need to return?

2. What is the value of the environment variable that you need to check for?

The answer to both is in the part of the instructions that I quoted above.

Answering these two questions is the very first step in fixing your code.

---

<div class="post-metadata">

**Author:** ![Elisart](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/elisart/32/134110_2.png) [@Elisart](https://forum.freecodecamp.org/u/Elisart)\
**Post date:** [November 29, 2021, 3:09am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/25 "2021-11-29T03:09:56Z")

</div>

Well I am trying to use secret tab to add the variable but I don`t see any difference .

---

<div class="post-metadata">

**Author:** ![JeremyLT](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jeremylt/32/291894_2.png) [@JeremyLT](https://forum.freecodecamp.org/u/JeremyLT)\
**Post date:** [November 29, 2021, 3:10am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/26 "2021-11-29T03:10:56Z")

</div>

> [@JeremyLT](#):
>
> Please answer these two simple questions:
> 
> 1. What is the message that you need to return?
> 2. What is the value of the environment variable that you need to check for?

I don’t think that you are reading what I’m posting.

I’m sorry, but I can’t help you without some interaction from you. Good luck with your code.

---

<div class="post-metadata">

**Author:** ![Elisart](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/elisart/32/134110_2.png) [@Elisart](https://forum.freecodecamp.org/u/Elisart)\
**Post date:** [November 29, 2021, 3:13am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/27 "2021-11-29T03:13:53Z")

</div>

Of course I read and I posted what my code is so far.

---

<div class="post-metadata">

**Author:** ![jwilkins.oboe](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/jwilkins.oboe/32/179497_2.png) [@jwilkins.oboe](https://forum.freecodecamp.org/u/jwilkins.oboe)\
**Post date:** [November 29, 2021, 5:27am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/28 "2021-11-29T05:27:05Z")

</div>

Hi @Elisart !

The link to share your replit code can be found here

 ![Screen Shot 2021-11-28 at 9.24.14 PM](https://global.discourse-cdn.com/freecodecamp/original/3X/b/3/b3a2378d9057d7f8d60783e4b0e2e28f9b3e382f.png)

As mentioned earlier, there are a few errors in your code.

First start by completing the first task.  
store the variable `MESSAGE_STYLE=uppercase` in the secrets tab.

---

<div class="post-metadata">

**Author:** ![damienfahey](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/damienfahey/32/225802_2.png) [@damienfahey](https://forum.freecodecamp.org/u/damienfahey)\
**Post date:** [December 3, 2021, 7:39am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/29 "2021-12-03T07:39:38Z")

</div>

Hope this helps!  
Look for Secrets (Environment Variables)

 ![Repli Scecrets ENV](https://global.discourse-cdn.com/freecodecamp/original/3X/b/7/b7c46788868fe1e9b4a495e040b736c11232c9ec.jpeg)

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [December 3, 2021, 8:17am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/30 "2021-12-03T08:17:13Z")

</div>

Here is the link to your editor

`https://replit.com/@Elisart/boilerplate-express-4`

You have this code:

```auto
app.get("/json", (req, res) => {
  var message = {"message": "Hello json"};
  if (mySecret=="uppercase"){
    message = {"message": "HELLO JSON"};
  }
    res.json(message);
});

```

1. In the Secrets the key should be `MESSAGE_STYLE` and the value should be `uppercase`.

2. You are not reading the environment variable. The `mySecret` variable is not assigned a value anywhere. You can just read the environment variable directly from process.env in the if statement.

`if (process.env.MESSAGE_STYLE === "uppercase")`

---

<div class="post-metadata">

**Author:** ![Elisart](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/elisart/32/134110_2.png) [@Elisart](https://forum.freecodecamp.org/u/Elisart)\
**Post date:** [December 4, 2021, 2:21am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/31 "2021-12-04T02:21:47Z")

</div>

Thank you so much for the help guys. I try to submit it but it is still not working. It is not accepted . The response of the endpoint `/json` should change according to the environment variable `MESSAGE_STYLE`

---

<div class="post-metadata">

**Author:** ![lasjorg](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/lasjorg/32/280761_2.png) [@lasjorg](https://forum.freecodecamp.org/u/lasjorg)\
**Post date:** [December 4, 2021, 3:23am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/32 "2021-12-04T03:23:16Z")

</div>

I don’t understand why you put the if statement where you did. It doesn’t do anything.

Your code right now:

```auto
app.get("/json", (req, res) => {
  var message = {"message": "Hello json"};
  if (mySecret=="uppercase"){
    message = {"message": "HELLO JSON"};
  }
    res.json(message);
});
if (process.env.MESSAGE_STYLE === "uppercase")

```

The if statement I wrote was supposed to be used instead of the one you have `if (mySecret=="uppercase")`.

* * *

You do understand that `mySecret` is an undeclared and unassigned variable, right?

It doesn’t somehow magically contain the environment variable. They are read from `process.env` and then whatever key you have given it, for example `process.env.MESSAGE_STYLE`.

Just think of it as an object you add properties to (key/value pairs).

```auto
const process = {
  env: {
    MESSAGE_STYLE: "uppercase",
	someOtherKey: "someOtherValue",
  }
}

process.env.MESSAGE_STYLE
// 'uppercase'

process.env.someOtherKey
// 'someOtherValue'

```

I might also suggest you revisit the JS section of the curriculum because you seem to have rushed it and are missing some basic knowledge which is very much needed for the later challenges in the curriculum.

---

<div class="post-metadata">

**Author:** ![damienfahey](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/damienfahey/32/225802_2.png) [@damienfahey](https://forum.freecodecamp.org/u/damienfahey)\
**Post date:** [December 4, 2021, 10:52am UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/33 "2021-12-04T10:52:55Z")

</div>

I think Replit looks for the Environment Variables inside Replits “Secrets”.

I tried to use an env file before, and I resulted using Replits “Secrets” to use Environment Variables.

 ![REPLIT ENV](https://global.discourse-cdn.com/freecodecamp/original/3X/4/0/4006b5b60b14a5d2d333f30bc6090835cd7d20d1.jpeg)

---

<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:** [June 4, 2022, 10:53pm UTC](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980/34 "2022-06-04T22:53:53Z")

</div>

Closed on June 4, 2022, 10:53pm UTC

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

[Previous page](https://forum.freecodecamp.org/t/i-need-need-help-with-full-code-the-env-file-on-replit/486980.md?page=1)
