read these instruction carefully. if u using replit look at this instruction Note : if you are using Replit, you cannot create a .env file. Instead, use the built-in SECRETS tab to add the variable.
then u can use it (idk how to use .env in replit cuz i using express) with process.env.NAME_VARIABLE, use if else for making that JSON uppercased
it’s the tab on the left with a locket simble, add the required variable name as key and add the required variable value as value, then press add value
Don’t need this const mySecret = process.env['MESSAGE_STYLE'] if you have this if (process.env.MESSAGE_STYLE === "uppercase")
Don’t redeclar response when you do not have to.
Don’t mix var and let, use let. If you are using var because of how you are scoping and redeclaring the response variable that points to a lack of understanding. The rules for let are meant to help you avoid such issues. Don’t reintroduce them. Declare the variable using letoutside the if/else code blocks and assign it the values inside the if/else code blocks.
The line let message = response serves no purpose. If you wanted the response variable to be named message you should just do that.
I have simplified it and my JSON output does change. You mentioned that I had my IF logic reversed so I changed that. JSON does change if I change my SECRET part of Replit from {"message":"Hello json"} to {"message":"HELLO JSON"}
Here is the code. I feel that I am still being stupid and have something wrong.
Hi Jeremy,
Sorry I am a beginner in JavaScript. Where do you usually declare the response variable? At the top or inside the app.get area?
Here is my attempt.
app.get("/json", (req, res) => {
...
It has something to do with how the handler function works.