Basic Node and Express - Use the .env File

Tell us what’s happening:

I don’t know what else to do at this stage. Is anyone able to help me ?
my code so far

require('dotenv').config()
let express = require('express');
const res = require('express/lib/response');
let app = express();
console.log("Hello World");
/*app.get('/', function(req, res){
     res.send("Hello Express");
})*/
app.use('/public', express.static(__dirname + '/public'));
app.get('/', function(req, res){
    res.sendFile(__dirname + '/views/index.html');
});
app.get('/json', function(req,res){
    let message = "Hello json";
    if(process.env.MESSAGE_STYLE === 'uppercase'){
        message = message.toUpperCase();
    }
    res.json(
        {"message": message}
    )
})

    

###Your project link(s)

solution: https://3000-freecodecam-boilerplate-1lg8tfsutmb.ws-eu117.gitpod.io

Your browser information:

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

Challenge Information:

Basic Node and Express - Use the .env File

what is inside your .env file?

where to find it ? I mean the.env file , I don’t have it in files provided

Please read the instructions, there is written there, it’s the point of this challenge.

i’ve created the env file , but still getting the error message . i don’t really know what’s wrong

what is inside the .env file? what is the exact name you gave to the file?

the file name is just .env
and inside the file I have MESSAGE_STYLE=uppercase
i used command touch .env to create it in gitpod terminal

ok, that’s good.

did you start the server with --watch? or did you stopped and restarted the server after last changes?

also there was an export at the bottom of the myApp.js file, did you remove it? or is it still there?

the export a the bottom is still there and i just restart it by run npm run start . the --watch i added it before in package.json

if you just restarted the server, did you also test the app?

^C
gitpod /workspace/boilerplate-express (main) $ npm run start

> fcc-learn-node-with-express@0.1.0 start
> node --watch server.js

Hello World
Node is listening on port 3000...
https://www.freecodecamp.org
*

that’s how my terminal looks like

it’s just opened a simple form like before , nothing changed

are you testing it submitting the link?

i’m submitting the link but still give me an error

what error are you getting?
what link are you submitting?