Basic Node and Express - Use the .env File

Tell us what’s happening:

Unable to pass the tester here is .env file content located in the root directory MESSAGE_STYLE=uppercase and this is the main part of my code app.get(‘/json’,function(req, res){
if(process.env.MESSAGE_STYLE === “uppercase” )
res.json({“message”: “Hello json”.toUpperCase()});
else
res.json({“message”: “Hello json”});
}) I went through all debugging mentioned in the issues of others as well

Your code so far

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/18.5 Safari/605.1.15

Challenge Information:

Basic Node and Express - Use the .env File

At the top of your myApp.js file, add require('dotenv').config() to load the environment variables.

Did you add it?

Did you restart the server after changing the .env file?

yeah first one I did and second one also for dozen times

can you open the browser console when you are running the tests? let us know what errors you find there

I did and there is no errors, only this issue which is not relevant clearly: “A form field element should have an id or name attribute”

that does not look right for the browser console on freecodecamp, on what page are you opening the console?

Thanks the problem is solved , it was that the link generated by ‘render’ already built upon /json route and the tester was probably trying to get result from link/json resulting in “not found”!