Basic Node and Express - Use the .env File

Tell us what’s happening:
I have no idea how to fix this. I am working on Replit and the problems are

  1. On /json page, it shows “message”: “Hello json”
  2. There is an alert showing in Replit says “1 secret out of sync”

image
Here is my Secrets setting on Replit.

Thank you in advance.
Your code so far

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

app.get("/",function(req, res){
  res.sendFile(__dirname + "/views/index.html");
})

app.use("/public", express.static(__dirname + "/public"));
console.log("Hello World");

app.get("/json",function(req,res){
  const mySecret = process.env['MESSAGE_STYLE'];
  if (mySecret === "uppercase"){
    res.json({"message": "HELLO JSON"});
  }else{
     res.json({"message": "Hello json"});
  }
})

Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/117.0.0.0 Safari/537.36 Edg/117.0.2045.60

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

Link to the challenge:

Hi there and welcome to our community!

Could you share a direct link to your repl code please?

https://replit.com/join/pbqligukgr-16863mnr

Is it this link?

That link works but if you just want to share your code rather than inviting me to join your repl it’s the url in the address bar when you’re viewing your code:
https://replit.com/@16863mnr/boilerplate-express

Anyhow, I ran your repl and submitted the live link to FCC and it passed.
You should always be submitting the link to the live project to FCC:
https://boilerplate-express.16863mnr.repl.co

(This is the address which can be found directly above the Webview window).

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