Use the .env File ERROR

Tell us what’s happening:
idk what im doing wrong!

var bGround = require('fcc-express-bground');
var myApp = require('./myApp');
var express = require('express');
var app = express();
const mySecret = process.env['MESSAGE_STYLE']
console.log(mySecret)

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

app.get("/json",(req,res)=>{
  let response = "Hello json"
  if(mySecret !== 'uppercase')response =response.toUpperCase()
  res.json({"message": response})
})

var port = process.env.PORT || 3000;
bGround.setupBackgroundApp(app, myApp, __dirname).listen(port, function(){
  bGround.log('Node is listening on port '+ port + '...')
});

Your project link(s)

solution: xpress - Replit

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

This is declared once out here in the global variable space. This means that the value of this variable won’t change. But the tests work by changing the environment variable while your app is running.

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