# Using .env to change a json package

**URL:** <https://forum.freecodecamp.org/t/using-env-to-change-a-json-package/425244>\
**Category:** Curriculum Help\
**Tags:** javascript\
**Created:** [October 12, 2020, 3:41pm UTC](https://forum.freecodecamp.org/t/using-env-to-change-a-json-package/425244 "2020-10-12T15:41:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![hussein.odeh](https://sea3.discourse-cdn.com/freecodecamp/user_avatar/forum.freecodecamp.org/hussein.odeh/32/181975_2.png) [@hussein.odeh](https://forum.freecodecamp.org/u/hussein.odeh)\
**Post date:** [October 12, 2020, 3:41pm UTC](https://forum.freecodecamp.org/t/using-env-to-change-a-json-package/425244/1 "2020-10-12T15:41:07Z")

</div>

**Tell us what’s happening:**  
I don’t know why it’s not working, if I change the variable MESSAGE\_STYLE to something different than uppercase, it passes the previous lesson, and using the console logs, supposedly it should work, maybe I am missing something?  
Thanks

```auto
// running tests The response of the endpoint

/json

should change according to the environment variable

MESSAGE_STYLE

// tests completed

```

**Your code so far**  
.env:

```auto
MESSAGE_STYLE=uppercase

```

myApp.js:

```auto

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

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

app.get("/json", (req,res) => {
  res.json({ "message": response });
  console.log(response);
}); 

 module.exports = app;

```

**Your browser information:**

User Agent is: `Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.75 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:** ![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:** [October 12, 2020, 4:38pm UTC](https://forum.freecodecamp.org/t/using-env-to-change-a-json-package/425244/2 "2020-10-12T16:38:20Z")

</div>

Hello there,

This is almost identical to the issue a camper was having in this post:

> [@Node and Express Json response Error](https://forum.freecodecamp.org/t/node-and-express-json-response-error/424549/2):
>
> Welcome, hasnatali. When do you expect this code to run? let response = '' ; console.log(process.env.MESSAGE\_STYLE); if(process.env.MESSAGE\_STYLE==='uppercase'){ // response = "Hello json".toUpperCase(); response = "Hello json".toUpperCase(); } else{ response = "Hello json"; } console.log('Bihy',{"style":response}) Also, 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 f…

Hope that helps

---

<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:** [June 1, 2021, 10:39am UTC](https://forum.freecodecamp.org/t/using-env-to-change-a-json-package/425244/3 "2021-06-01T10:39:05Z")

</div>

Closed on June 1, 2021, 10:39am UTC


