Welcome there,
I am not sure what you are experiencing in Replit, as I cannot replicate any issues. Also, I am not sure what your Glitch code is, but with the code you linked to there is an issue:
var response;
if (process.env['MESSAGE_STYLE'] === "uppercase") {
response = "Hello json".toUpperCase();
} else {
response = "Hello json";
}
app.get('/json', (req, res) => res.json({"message": response}));
Consider when the code runs:
- Node application starts:
- All variables are defined (e.g.
response = "HELLO JSON"
) - All routes are attached to app
- All callbacks are defined for what should happen if a route is reached
- Now, a route is requested (e.g.
/json
):
- The route has been defined to respond with some form of
response
whatever its value is -
response
is still"HELLO JSON"
- The environment variable is changed (the fCC tests do this for you)
- The script is still running from previously, so
response
is not redefined/changed - The route
res
is always the same
Hope this helps