Basic Node and Express - Use the .env File

Tell us what’s happening:
Describe your issue in detail here.

i cannot understand why is it not being validated by the test correctly? below is my snippet:

let express = require('express');
let app = express();
const msgStyle = process.env.MESSAGE_STYLE;

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

  res.send(__dirname + "/views/index.html");

app.get("/json", (req, res) => {
var response
  if(process.env.MESSAGE_STYLE === "uppercase"){
    response = "Hello json".toUpperCase();
  } else {
    response = "Hello json";

    "message": response

i am using replit dot com for this so i suppose the link would not be working if you test it but it is still indicated below

Your project link(s)


Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/ Safari/537.36

Challenge: Basic Node and Express - Use the .env File

Link to the challenge:

can you please share repl link, where “code can be seen” as well, here its only showing output!!

also have you looked this from instructions

At the top of your myApp.js file, add require('dotenv').config() to load the environment variables.

happy learning :slight_smile:

try this
first install dotenv - npm i dotenv
then create a .env file and
write your msgStyle key, value

var resolvedPath = path.resolve(filePath);
 return res.sendFile(resolvedPath);

Make sure the environment variable was added correctly

You should fix your file serving as well.

use this line
const app = express();