Help with .env on boilerplate-express

“The trouble is I used the hint, like it said and created the secret for the this.”
https://boilerplate-express.jessicawoods03.repl.co

it kind of doesn’t work…I am on “Use the .env file”

I used the concepts like it asked…
I have key = MESSAGE_STYLE
I have value= uppercase
Any help is awesome :slight_smile:

The link to the code would help.

Are you checking the value of the environment variable inside of your GET function? The tests work by changing your environment variables, so you can’t check the value once in the global scope.

1 Like

Oh sorry- I don’t know which link to post? https://replit.com/@JessicaWoods03/boilerplate-express ?
I hope this ones it?

Try using the secret tab in replit to set environment variables, the .env files are deprecated

1 Like

OK, so this does look like it is your problem. You can’t check the secret on line 1. You need to do it inside your function on line 13.

1 Like

Oh?? Well I will give it try, thanks so much Jeremy :slight_smile:

I moved it inside the app.get()- still isn’t working-
Error: The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE

You didn’t move it inside the get… It is below the get.

1 Like

app.get //this is the git bracket begins->("/json", This is a req, res function ->(req, res)=>{res.json({“message”: “Hello json”});

const mySecret = process.env[‘MESSAGE_STYLE’];

var responce = “Hello json”.toUpperCase();

if (mySecret.MESSAGE_STYLE === “allCaps”) {

response = “Hello json”.toUpperCase();

} else {

response = “Hello json”;

};

});<- this is where the git bracket ends for the app.get( “blah”-location " blah" function const, var, if() else statement);
Is my brackets off? I am still a bit confused?

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.