Need help creating env file in replit

Tell us what’s happening:
I’m using Replit for JS project but when I don’t know how to use the built-in SECRETS tab to add the variable. Can someone help me ?

Your project link(s)

solution: https://replit.com/@shirosun1/boilerplate-express

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

Hi @tungduon1710 !

I have edited the title of your post.
Please avoid placing links in the title since we cannot click on them.

Open up the secrets tab and place the key(MESSAGE_STYLE) and value(uppercase)
inside and click add new secret.

Screen Shot 2021-05-28 at 10.57.09 AM

1 Like

Thank you . But when i I write my code like this :

app.get("/json", function(req, res) {
if(process.env.MESSAGE_STYLE === “uppercase”){
res.json( message = “Hello json”.toUpperCase());
} else {
res.json( message = “Hello json”);
}
It said I’m wrong. Can you explain about this ?

you need to give back an object in the form {"message": "Hello json"} like in the previous challenge (https://www.freecodecamp.org/learn/apis-and-microservices/basic-node-and-express/serve-json-on-a-specific-route)
not just a string

2 Likes

A post was split to a new topic: Need help with env file challenge

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