Tell us what’s happening:
I’m on the .env file exercise and it’s asking me to turn the response object’s message to uppercase based on the state of the MESSAGE_STYLE. I did it in 3 ways, even hardcoding it to the necessary values but once I submit the tests throw an error. I know the app does what it should since I’m testing it with Postman, I went over the code and the exercise requirements multiple times and it just doesn’t accept it. Am I missing smth obvious or is this a bug?
The app returns
if (process.env.MESSAGE_STYLE === "uppercase"):
{
"message": "HELLO JSON"
}
else:
{
"message": "hello json"
}
Your code so far
.env file => MESSAGE_STYLE=uppercase
app.get("/json", (req, res) => {
let messageStr = 'hello json';
if (process.env.MESSAGE_STYLE === "uppercase") {
messageStr = messageStr.toUpperCase();
}
let jsonResponse = {message: messageStr}
res.json(jsonResponse);
});
Your browser information:
User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_3) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/80.0.3987.106 Safari/537.36
.
Challenge: The response of the endpoint /json
should change according to the environment variable MESSAGE_STYLE
Link to the challenge:
https://www.freecodecamp.org/learn/apis-and-microservices/basic-node-and-express/use-the-.env-file