Tell us what’s happening:
I am getting this error: The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE`
Your code so far
Code in .env file: MESSAGE_STYLE = uppercase;
One thing to mention: A few users are having issues with the incorrect .env variable:
To debug: add this line somewhere in your code:
console.log(process.env.MESSAGE_STYLE)
If you get undefined in the logs, and you have defined it, you need to add the following package: dotenv, then call it at the top of your script: require('dotenv').config();
As for your code, the instructions are:
…if process.env.MESSAGE_STYLE equals uppercase . The response object should become {"message": "HELLO JSON"} .
As suggested, I have put console.log(process.env.MESSAGE_STYLE); at the top of myApp.js file. As a result, I am seeing uppercase in the console, which seems to be fine. It looks like I have defined MESSAGE_STYLE at .env file perfectly.
However, I am still getting the same error while trying to submit my solution on FreeCodeCamp: The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE`
How can I fix the issue?
Another thing. I have changed "message": "Hello json" to "message": "HELLO JSON", as stated in the challenge.
In the .env file, there should be no spaces around = and in your myApp.js file, if MESSAGE_STYLE is uppercase, the you want to send HELLO JSON else hello json