Use .env file not working

Tell us what’s happening:

my code is not working, please tell me if there is any mistake in my code. my code is as follows:-
Your code so far
if (process.env.MESSAGE_STYLE=‘uppercase’){
app.get(’/json’, function(req, res) {
res.json({ “message”: “HELLO JSON” })
else {
app.get(’/json’, function(req, res) {
res.json({ “message”: “Hello json” })


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 6.1; ) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36.

Challenge: undefined

Link to the challenge:

Okay so your task is:
Store the variable MESSAGE_STYLE=uppercase in the .env file.
Then tell the GET /json route handler that you created in the last challenge to transform the response object’s message to uppercase
if process.env.MESSAGE_STYLE equals uppercase .
The response object should become {"message": "HELLO JSON"} .

As we look it over we know a few things
1: The outcome must be in all caps
I can’t see anywhere in your code a function that would excecute this or , a function that implies this.
2: And we need to check what the value of the environment variable is.

1 Like

Are you trying to compare or assigning? process.env.MESSAGE_STYLE=‘uppercase’

Mind the = for assigning and == or === for comparing in Javascript.

1 Like