.env file for node

Hello, I’m doing the node and express exercises and I’m stuck on the .env file. The goal is to write “Message_Style=uppercase” in the file and then use that to change the api call from the previous exercise.
I can’t think of what that really means though. Here’s my best guess:

app.get(’/’, function(req,res) {
if(process.env.Message_Style === ‘uppercase’){
res.send({message: ‘HELLO JSON’);
}
else {
res.send({message: ‘Hello json’});
}

This works I guess but it won’t accept it as an answer. I only get “Unexpected token N in JSON at position 0” as an error.

how does your .env file look like?

# Environment Config

# store your secrets and config variables in here
# only invited collaborators will be able to see your .env values

# reference these in your code with process.env.SECRET

SECRET=
MADE_WITH=
MESSAGE_STYLE=uppercase

# note: .env is a shell file so there can't be spaces around =

I’ve edited your post for readability. When you enter a code block into the forum, precede it with a line of three backticks and follow it with a line of three backticks to make easier to read. See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

markdown_Forums

I see the problem now.

Then tell the GET /json route handler

You are not giving it a correct route.

Hello,
First you PATH is incorrect it should be "/json"

Then your variable should be in uppercase as in the .env file

process.env.MESSAGE_STYLE === ‘uppercase’

and finally you can use "Hello json".toUpperCase()

Hopefully this correction will help others…