Nodejs test not passing!

Tell us what’s happening:
Describe your issue in detail here.
As hard as I try, the tests don’t pass. I’m really not sure what I’m doing wrong.
I’m supposed to check a an environment variable names MESSAGE_STYLE and based on its value, if it’s uppercase I return a JSON encoded js object with the key being message and the value being HELLO JSON and if not, the value will be Hello json.
This is not complicated but I can’t pass the test.

Your project link(s)


Your browser information:

User Agent is: Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.212 Safari/537.36 OPR/76.0.4017.154

Challenge: Use the .env File

Link to the challenge:

Hello there,

The issue, is you are not following this part of the instructions:

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

Take some time to think about when the app runs, and when the lines of code are executed.

Hope this helps

1 Like

Hello and thanks,
This worked. As I understand FCC is setting some other value for the MESSAGE_STYLE env variable in the request and I was missing it by checking the env variable only outside of the GET request and response.
But I’m wondering how an environment variable is set through a request? Are the local ones overridden if the keys match to the keys in the key/value pairs in the URL or post data? I’m curious :slight_smile:

Well, if you are really interested, here is the fcc-express-bground-pkg (in your package.json: fcc-express-bground-pkg/index.js at master · freeCodeCamp/fcc-express-bground-pkg · GitHub

So, it is not set through the request, because the package is a part of your Node app - therefore, process is available to the package.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.