Basic Node and Express - Use the .env File

Tell us what’s happening:
This seems to work but the tests don’t pass.

My Secrets in replit is set to

key=MESSAGE_STYLE
value=uppercase

This is my code:

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

console.log("Hello World");


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

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


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 project link(s)

solution: https://replit.com/@moxelliot/basic-node-and-express-fccjson

Your browser information:

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

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

Link to the challenge:

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