Use the .env File Challange

Tell us what’s happening:

I am getting this error even I feel everything seems fine.

// running tests The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE
// tests completed

I need another eyes to check what I am doing wrong.
P.S. I created SECRET via replit.

Your project link(s)

solution: express - Replit

Your browser information:

User Agent is: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/102.0.0.0 Safari/537.36

Challenge: Use the .env File

Link to the challenge:

you seem to have a small typo, check that your code gives back the two requested strings:

should either be {"message": "Hello json"} or {"message": "HELLO JSON"}

Thanks for update. I guess I fixed the typo and tried all possible variation but it keeps giving error.

now you have a different issue, you have moved taking the value of process.env["MESSAGE_STYLE"] outside of the route, which doesn’t work because the value of the env variable is changed while the tests run

thanks for heads up. but what I meant with possible variation is this too. I changed it to former version. I stopped and restarted the server. and retest. still having same error.

P.S. when I visit URL, I get the message without any problem.

Screenshot 2022-06-19 at 15.58.24

that’s what I am talking about

you need to move the point in which you take the value of the environment variable inside the /json route

1 Like

ohhh my bad! of course! thanks for help!