Basic Node and Express - Use the .env File

Tell us what’s happening:

I am not able to make this pass. I have tried multiple and resorted to copying what others have copied of off the internet.

var express = require('express');
require('dotenv').config();
var app = express(); 
process.env.MESSAGE_STYLE == "uppercase";
console.log(process.env.MESSAGE_STYLE);

//let app = express();
//console.log(process.env//.VARIABLE_ONE)


//app.use('/pics', express.static(__dirname + '/images'));
//console.log("Hello World");
/** app.get("/", (req,res)=>{
  res.send("Hello Express");

});*/

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

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


/**6)use the .env File to configure app*/

app.get("/", function(req, res){
  res.sendFile(__dirname+ '/views/index.html');
app.use(express.static(__dirname + "/public"));
})
//7.use the .env file
app.get("/json", (request, response)=>{
  if(process.env.MESSAGE_STYLE ==uppercase){
     response.json({"message" : "Hello json".toUpperCase()})
  }else{
    response.json({"message": "Hello json"})
  }
});
module.exports = app;

###Your project link(s)

solution: https://3000-freecodecam-boilerplate-0mhpr76j63l.ws-us116.gitpod.io

Your browser information:

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

Challenge Information:

Basic Node and Express - Use the .env File

you don’t have an uppercase variable. You need to make the comparison of process.env.MESSAGE_STYLE with a string


I’ve edited your code for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (').

I’m not sure I understand. I have tried making uppercase a string, but I still can’t make it pass.

did you restart the server after the changes? what’s inside your .env file?

I have…

MESSAGE_STYLE=uppercase…that is what is in the process.env file

it should be .env not process.env

That worked. Thank you!