Tell us what’s happening:
According to the challenge, I have located the process.env file in the root folder (ie. same place as the myApp.js file. I create a variable called “response”, I use an if-statement to check if(process.env.MESSAGE_STYLE == “uppercase”)
and if true, I set response to response.toUpperCase();
All that seems to work BUT the if statement. I don’t think it’s able to read the .env file?
I’ve tried to troubleshoot by logging “process.env.MESSAGE_STYLE” to the console, even as a boolean by comparing it to the string “uppercase”. In the first scenario I don’t get an output, in the second it returns “false” despite my process.env file containing the text MESSAGE_STYLE=uppercase
I’ve even tried to troubleshoot by finding another working solution from the forums and copy-pasting it into my own program, but it gives me the same errors. So I can deduct that it’s probably an issue with my .env file, either it’s location or it’s content.
Your project link(s)
solution: https://express-nodejs.andreasguldborg.repl.co
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/89.0.4389.90 Safari/537.36
.
Challenge: Use the .env File
Link to the challenge: