Basic Node and Express - Use the .env File

Basic Node and Express - Use the .env File
0

For Glitch users do this:
Bottom left -> tools -> logs : opens the logs window. There select debugger option and you will see that there is a new file “.env” there. (How/ Why that happens I don’t know) In the env File enter the MESSAGE_STYLE variable in this manner.

MESSAGE_STYLE=uppercase

Next in myApp.js enter this:

app.get("/json", function(req,res){
  var msgobj = {"message" :"Hello json"};
  if(process.env.MESSAGE_STYLE == 'uppercase'){
     msgobj.message = msgobj.message.toUpperCase();
    }
  res.json(msgobj);
});