Tell us what’s happening:
I have created a local.env file with code:
MESSAGE_STYLE=“uppercase”;
var express = require(‘express’);
var app = express();
console.log(“Hello World”);
// --> 7) Mount the Logger middleware here
var absolutePath = __dirname + ‘/views/index.html’;
var assets = __dirname + ‘/public’;
app.use(express.static(assets));
app.get(’/’,function(req,res){
res.sendFile(absolutePath);
});
app.get(’/json’,(req,res) => {
var response = “Hello json”;
if(process.env.MESSAGE_STYLE == “uppercase”){
response = response.toUpperCase();
}
res.json({
message: response});
});
This is my code. But, it still gives message Hello json here,
https://smiling-cowl-si8f4svr5a.glitch.me/json
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/79.0.3945.88 Safari/537.36
.
Link to the challenge:
https://www.freecodecamp.org/learn/apis-and-microservices/basic-node-and-express/use-the-.env-file