Basic Node and Express - Use the .env File

Tell us what’s happening:

Can anyone tell me why is the text failed? here is the test output:
// running tests The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE // tests completed
here is my code:

let express = require('express');
const req = require('express/lib/request');
const res = require('express/lib/response');
const path = require('path');
let app = express();


app.get("/", (req, res) => {
    // res.sendFile('/views/index.html');
    res.sendFile(path 

###Your project link(s)

solution: https://3000-freecodecam-boilerplate-0cylh30w4h8.ws-eu115.gitpod.io

Your browser information:

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

Challenge Information:

Basic Node and Express - Use the .env File

Did you follow these instructions?

. At the top of your myApp.js file, add require('dotenv').config() to load the environment variables.

hbar1st,
Thank you for your reply.
I thought ‘dotenv’ is just required for those who are working locally. I already added that and still not passing.

FYI, the object is being served , but still not passing, that’s my question, here is a copy of the served page:
{
“message”: “HELLO JSON”
}

Please advise.
Regards.

can you post all your code because what you posted seems to be just partial?

Thank you very much for your co-operation. The challenge has been passed.
Regards,
Addel

1 Like

what turned out to be the issue?

It sees that I paste the solution and just hit enter while I had to click on button of “I have completed the challenge” instead.

1 Like