Cannot Pass Test: Use .env File Section

Tell us what’s happening:
I cannot pass test in Use .env File section even I followed the steps and got the same result

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

const mySecret = process.env['MESSAGE_STYLE']

app.get("/json", (req, res) => {
    if (process.env.MESSAGE_STYLE === "uppercase ") {
    message: "Hello json".toUpperCase()
} else {
    message: "Hello json"


Your project link(s)


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/93.0.4577.63 Safari/537.36

Challenge: Use the .env File

Link to the challenge: text

1 Like

Welcome there,

You are not really following this section of the instructions:

…in the /json GET route handler you created in the last challenge…

Hope this helps


"uppercase " you have a space at the end.

1 Like

I am also having trouble passing this question.

That’s my code:

const mySecret = process.env[‘MESSAGE_STYLE’]

app.get(’/json’, function(req, res){
if(mySecret == ‘uppercase’) {
res.json({message: “HELLO JSON”});
}else {
res.json({message: “Hello json”});

and I see my code works here
but I cannot pass the test. Please help!

@samtaitai You need to move const mySecret = process.env['MESSAGE_STYLE'] inside the app.get handler function.

BTW, in the future, if you have a question please open a new thread.

1 Like

passed it, thank you!