My code didn't work

Tell us what’s happening:
After a lot of attempts, I still get this message. Please help me
The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE

Your code so far

process.env.MESSAGE_STYLE = "uppercase";
if (process.env.MESSAGE_STYLE == "uppercase") {
    app.get('/json', function(req, res) {

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

By hardcoding with this line, your code will always make the message uppercase regardless of what is actually in the .env file. Make the changes in the .env file.

Hello there,

You need to create a .env file, and place MESSAGE_STYLE=uppercase in it. No ending ;, and no spaces between the =. Also, the logic (if) should be within the anonymous function within the GET handle.

Otherwise, please note: It is difficult for us to help further without seeing more of your code. Ideally, could you please share the link to your project code?

I’m sorry, I still don’t get it. Here’s my link

[My solution link](

As I know the process.env is creating .env file, isn’t it?

Does it mean I need to create


Then I assign to

process.env.MESSAGE_STYLE = “uppercase”


No. You need to create a file with the name .env (the dot must be included)

This is a special file. Read more about it here:

Then, you need to create a variable in it like this:


To access the value of a variable in a .env file, you use:


Also, you should not have 2 /json routes. The instructions are:

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

Hope this clarifies.

1 Like

At first the terminal seems ok, and client can load the file.
And then I got lof of error and client going down due to errors.

This is my code

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

I also imported the dotenv package based on the tutorial

Hello there,

You are not quite satisfying this:

… to transform the response object’s message to uppercase if process.env.MESSAGE_STYLE equals uppercase .

There should always be a response…

I’d changed my code to

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

The error say sytanx error.

SyntaxError: Unexpected token s in JSON at position 0
    at JSON.parse (<anonymous>)
    at /home/runner/boilerplate-express/node_modules/fcc-express-bground/index.js:91:26
    at IncomingMessage.<anonymous> (/home/runner/boilerplate-express/node_modules/fcc-express-bground/index.js:33:7)

May I know the incorrect syntax is?
I’m very confused here, sorry.

Your /json route must always respond with something. Currently, it is only responding, when process.env.MESSAGE_STYLE === 'uppercase'

1 Like

Is this not a response?

The above is not. What you have here is:

res.json({"message": "Hello json".toUpperCase()})

However, I will reiterate:

What are you responding with, when process.env.MESSAGE_STYLE !== 'uppercase'?

1 Like

I get it Sir. Thank you very much!

What link are you submitting?

I assume the error was coming from the tests trying to parse a JSON response from a route which did not respond with anything.

Yes it was :sweat_smile: :sweat_smile: