Use the .env File

I am using replit so I have to use the Secrets tool in order to do this but what I am doing isn’t working. Need help

let express = require('express');
let app = express();

app.get("/", (req, res) => {
  res.sendFile(absolutePath = __dirname + '/views/index.html');
});

app.use("/public",express.static(__dirname + '/public'));

app.get("/json", (req, res) => {
  res.json({
    "message": "Hello json"
  });
});

const mySecret = process.env['MESSAGE_STYLE']




































 module.exports = app;

What course are you busy with? Be more precise, give more information.

You must have not seen the link to the problem that I included :thinking:

I didn’ see, sorry! I will take a look.
Is about:

The response object should either be {"message": "Hello json"} or {"message": "HELLO JSON"} , depending on the MESSAGE_STYLE value.

Your json response is not conditional on the value of MESSAGE_STYLE. You need to write a conditional statement which accounts for this.

I changed it but it’s still not working

let express = require('express');
let app = express();

app.get("/", (req, res) => {
  res.sendFile(absolutePath = __dirname + '/views/index.html');
});

app.use("/public",express.static(__dirname + '/public'));

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"});
  }
});






































 module.exports = app;

Nevermind @igorgetmeabrain . Thank you! was a little mistake on my end. Fixed it:

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"});
  }
});

You have to add this before app.get:


with :
image

hello what is the corrected one am having exact problem

Specifically, what’s the problem? Please provide some more information!