Tell us what’s happening:
I have no idea why this isn’t working, i have the variable set in my env file but it still doesn’t do anything. Any advice?
Your code so far
if (process.env.MESSAGE_STYLE==‘uppercase’){
app.get(’/json’, function(req, res) {
return res.json({ ‘message’: ‘HELLO JSON’ })
});
} else {
app.get(’/json’, function(req, res) {
return res.json({ ‘message’: ‘Hello json’ })
});
}
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.138 Safari/537.36
.
Challenge: Use the .env File
Link to the challenge:
Learn to code. Build projects. Earn certifications.Since 2015, 40,000 graduates have gotten jobs at tech companies including Google, Apple, Amazon, and Microsoft.
Do you have the package installed? What does process.env.MESSAGE_STYLE
log out?
I do have it installed on glitch and it logs out uppercase
Try a triple ===
for comparison and then log out in that block. Does the code run?
Tried it doesn’t change anything
console.log before your app.get
, does it run?
It logs out uppercase and when i visit https://pinnate-restaurant.glitch.me/json {“message”:“HELLO JSON”} shows up as it should but when i check the solution it fails. Changing the variable does change the message so it should work just fine right?