Use the .env File Challenge fix error on Replit

I want to share a solution that worked for me in the Node & Express challenges. I’m writing my answers in Replit, I wrote the key and value in the updated “Secrets” section of Replit for .env variables. After that writing the request with the json response could not pass the challenge. Looking for the answer in the forum, I found this answer thanks to @rizquadnan:

const response = "Hello json";
app.get("/json", (req, res) => {
    message: process.env.MESSAGE_STYLE === 'uppercase' ? response.toUpperCase() : response

however, it did not work to pass the challenge either. I finally saw in the server.js file at line 24:

var port = process.env.PORT || 3000;

and just removed “process.env.PORT ||” and then I passed the challenge. I hope this helps someone else who is stuck with this.

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