Tell us what’s happening:
I have tried different approach, yet the code is not running.
###Your project links
solution: boilerplate-express - Replit
Your browser information:
User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/122.0.0.0 Safari/537.36
Challenge Information:
Basic Node and Express - Use the .env File
Are you using the Replit Secrets for the environment variable?
You can’t use .env
files with Replit
so I should use another IDE for this?
No. Just follow the docs I linked to.
Click the Secrets button and add MESSAGE_STYLE
as the key and uppercase
as the value.
I have done just that, is still not working
The code you had before worked. Now you have 4 different /json
routes and none of them have correct code. The issue is not the environment variable but your code.
app.get(“/json”, (req, res) => {
process.env.MESSAGE_STYLE ===“uppercase”
const mySecret = process.env.MESSAGE_STYLE;
if (mySecret === "uppercase") {
res.json({"message": "HELLO JSON"});
} else {
res.json({"message": "Hello json"});
}
});
this is what I have and still not passing the test, if this is wrong then please point out possible solution, I will keep brainstorming on it
thank you for your response thus far
When I fork your Replit and add uppercase
as the value for the MESSAGE_STYLE
key it passes the tests.
this is what I have from my end, I know I am not supposed to share these but at this point I need to, please any further help will go a long way
Are you submitting the correct URL? It should be the one you get when clicking the “New tab” button by the preview window.
this is the link I am submitting
That is the editor.
You have to summit the URL from the page you open using the New tab button.
I honestly don’t understand this point.
please can you explain more, new tab or replit or my browser
Click that button and use the URL from the address bar from that new tab it opens.
Thank you for your time, I am glad to inform you the exercise have been passed
Gracias
system
Closed
October 15, 2024, 11:19am
16
This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.