Hello, I’m stuck for several hours now at this part of the Basic Node lessons.
Seems like a really simple task (link) but my solution never gets accepted.
Many other people struggled with this aswell, I looked at other topics first for a solution but neither of those worked.
Is this step broken or is there really anyone who can solve this?
Any code outside of the route, will only be computed once. This happens at startup of the server, and never again. So, messageStyle never changes, and the else statement will never run.
I wish it did but I only wrote it like that because I have tried 10 other different ways that didn’t work either.
Combine that with the fact that many topic have already been created asking the same question, all of them without solution.
Also the “get a hint” section of the course doesn’t really say anything,so I’m wondering if it isn’t just broken.
Well, unfortunately, there could be many things which could go wrong.
Fortunately, we are developers…and developers debug. Would you mind doing the following:
Outside of any routes, add this: console.log(process.env.MESSAGE_STYLE);
– Start the server (in Repl, click RUN)
– Take a note of what is printed to the console
If you see undefined, add dotenv to your package.json, and place this code at the top of your myApp.js file: require('dotenv').config();
Repeat the above
Ensure the server is running, on the fCC /learn page, submit your project, and open the browser console (Ctrl + Shift + I)
– Take a note of the output
Open the app in a full browser window, and navigate to this route: /_api/use-env-vars
– Take a note of:
What is printed to the window
What appears in this browser window’s console (Ctrl + Shift + I within the app window)
Literally copied it but only works or gets accepted as a correct solution on one of the two projects.
Not really sure why but I will happily leave it be.
The editor is warning that there are syntax errors. Namely, the quotation marks used are not standard. This is often the case, when coding on a mobile phone, or with predictive text.
Also, the commented out code should not be commented out.
yaaaaay it works x)
youre right one of the quotes was neither ’ nor "
about the commented out, I understood from the instruction note here that it needs to be commented out…
tyvm!