Use the .env File express on repl

What’s my mistake ?
#express #repl

MESSAGE_STYLE=uppercase must be in a .env file.

1 Like

found this on stackoverflow

let messageObject = {“message”: “Hello json”};
app.get(’/json’, function(req, res) {
if (process.env.MESSAGE_STYLE === ‘uppercase’) {
var u_=JSON.parse(JSON.stringify(messageObject ));
return res.json(u_);
} else {
return res.json(messageObject);

Hello there,

For future posts, please post a link to your project, and not a screenshot of code. This is difficult to work with, and you are less likely to get help.

Also there is not need for this. It is much more code than necessary, and is convoluted.

As @jenovs said, you need to create a .env file, and store the variable in it.

1 Like