I can't pass the challenge even if my code is working

I successfully completed this challenge, everything is working just fine in Heroku or on my local server. but I can’t complete this challenge .

all I get is this error:

  The response of the endpoint

/json

should change according to the environment variable
MESSAGE_STYLE

for more than 3 days now!
I mean, everything is just working fine… but I still can not complete this challenge.

that’s my code :

    app.get('/json', function(req, res) {
        return res.json({"message" : "HELLO JSON"})
    });
}else {
    app.get('/json', function(req, res) {
        return res.json({"message" : "hello json"})
    });
};

my project link(s)

solution: https://morning-garden-82101.herokuapp.com

Challenge: Use the .env File

Link to the challenge:

You only need one get for the /json endpoint and you need to access the environment variable inside the route handler not outside it.

We can’t see your code on Heroku so you have to post your repository or use something like Replit. Or at least post all your code.

this is my repo : GitHub - rabieOuallaf1/boilerplate-express: boilerplate-express

app.get("/json", function(req, res){
    if (process.env.MESSAGE_STYLE === "uppercase") {
        res.json({"message": "HELLO JSON"});
    }
});

You are only handling one of the two conditions. Where is the lower case response?

just I was playing with the code and I forgot about it, sorry.
I fixed this already and I still have the same problem…

I’m using glitch.com now. I hope you’ll take a look again: Glitch :・゚✧

I see a small typo in the lowercase response:

Then, in the /json GET route handler you created in the last challenge, transform the response object’s message to uppercase if process.env.MESSAGE_STYLE equals uppercase . The response object should either be {"message": "Hello json"} or {"message": "HELLO JSON"} , depending on the MESSAGE_STYLE value.

1 Like

@rabie456 Did you find the error?

// expected object
{message: "Hello json"}

// Your object
{message: "hello json"}
1 Like

thank you so much! I don’t know why I didn’t see this.

thank you so much <3.

1 Like