Use the .env File - Can't submit this task

Hello everyone, I couldn’t submit the answer for .env file Task. I was trying to figure out a solution for a while. I saw similar posts regarding to this problem. But I was not able to find out a solution for myself. Below I have attached replit link.

Your project link(s)


Your browser information:

User Agent is: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/94.0.4606.81 Safari/537.36

Challenge: Use the .env File

Link to the challenge:

const mySecret = process.env['MESSAGE_STYLE']

You can’t check the value of the environment variable in the global space. If you do this, then your application cannot respond to changes in the environment between API calls. You need to check the current value of this environment variable inside of your app.get() method.

1 Like

Thank you very much for your reply. I did the changes as you said. but it is still not working.

Error:- The response of the endpoint /json should change according to the environment variable MESSAGE_STYLE

The method looks OK to me now. Are you sure you set the Secret correctly?

1 Like

If anything goes wrong, please correct me

When I copy-pasted that function into my repl, it worked ok.

What happens when you submit the project link?

I also went head and simply added the secrete to your code without changing anything and it passed


It’s not working for me

I get a 404 when hitting the test endpoint, not sure why (obviously making sure the project is running first).

Try forking your own project (use the three dots in the list of projects, i.e. “My Repls” section). Re-add the environment variable, and try the submit again.

Some people for whatever reason have issues with replit. BTW, I too pass the test when I fork your code, so it should be passing.

1 Like

@JeremyLT caryaharper @lasjorg Finally i have solved this task. i just changed line 16 and i forked my own project as @lasjorg said. Thank you all for helping me.
Here is my final Solution.

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