Basic Node and Express - Use the .env File

I am not able solve below problem, Can I know where I am doing wrong.

let express = require(‘express’);
let app = express();

app.get(“/json”, (req, res) => {
const mySecret = process.env[‘MESSAGE_STYLE’]
if(mySecret === “uppercase”)
{
res.json({message:“HELLO JSON”});
}
else
{
res.json({message:“hello json”});
}
});

hello and welcome to fcc forum :slight_smile:

  • try using require('dotenv').config() at top, see if that resolves it

happy learning :slight_smile:

Double check this message

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.