process.env.MESSAGE_STYLE == “uppercase” initialize it;
var express = require(‘express’);
var app = express();
process.env.MESSAGE_STYLE=“uppercase”;
// --> 7) Mount the Logger middleware here
app.use(
express.static(__dirname + “/public”));
// --> 11) Mount the body-parser middleware here
app.get("/json",function(req,res){
if(process.env.MESSAGE_STYLE==“uppercase”)
res.json({“message”: “HELLO JSON”})
else res.json({“message”:“Hello json”})
});
this works.
Make sure the url you upload ends in ‘/’ and not ‘/json’
thanks ,i had deleted this .env file earlier
now it should work on your glitch
You are right. The whole of it including “module.exports = app;” worked for me after Avery long struggle. Thank you and best regards.
Spent a lot of time on this as well, for me the solution was literally closing my repl.it project, going back to their home page and opening the repl.it project again from the My Repls page.
Very frustrating when you are trying to learn and turns out your code was correct the entire time.
thank you very much. i think mine just got solved. guys i suggest if your case still persists, you should start a new project, paste the git clone repos from the introduction and finally copy and paste all off these post. (i even recommend you do away with all the comments) #ENDSARS IN NIGERIA. PLEASEEEEE…
Hi I created the env. file and input the code MESSAGE_STYLE=uppercase in the file . can you tell me what im missing or misplacing.
Please refrain from spamming multiple topics with the same question. Also, many of these topics are old and outdated, thus are unlikely to be useful.
If you have a question about your own code, please use/open your own topic, providing all the necessary information.
