I need need help with full code the env. File on replit

Could anybody help with the full code for env. File on replit?

Thank you

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

We don’t provide code for users. What are you having trouble with?

How can I do the code on replit?

What is your current code? Can you share a link to your repl?

if (process.env.VAR_NAME === "allCaps") {
  response = "Hello World".toUpperCase();
} else {
  response = "Hello World";
}

Is that all of your code? That seems like too little code to debug.

In any case, it looks like you are not using the strings required by the instructions.

Create a .env file in the root of your project directory, and store the variable MESSAGE_STYLE=uppercase in it.

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.

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

Thank you! It doesn`t work. I am still confused.

Did you read both of my posts?..

What is your current full code?

Yes I read. I posted on the top of the comments

I am working on replit.

Ok, if that is your full code, then you have deleted a bunch of stuff from previous challenges. You should go back and look at how to add a GET request handler.

A link to your repl would be very helpful.

https://boilerplate-express-4.elisart.repl.co

That’s the link to the live view of your application. To best help, I need the link to your code.

app.use("/public",express.static(__dirname + "/public"));

app.get("/json", (req, res) => {
  res.json({
    messagge: "Hello json"
  });
});

if (process.env.VAR_NAME === "allCaps") {
  response = "Hello World".toUpperCase();
} else {
  response = "Hello World";
}

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor (</>) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).

This code is not part of the GET handler, so it can’t possibly have any effect upon what happens when someone calls the GET handler.

Also, your environment variable will never be set to allCaps. That isn’t the value you were told to check for.

Also, this is not the message you were told to use.

How can I do the code on replit?

Well, you need to fix your get request so that it returns the correct message based upon the value of the process.env.MESSAGE_STYLE variable.

Do you know what part of the instructions I quoted above tells you what message to use?

Do you know what part of the instructions I quoted above tells you what the environment variable value you need to check for?

We do not write out answers for users on this forum, but we will help you get your code fixed if you work with us.

I already read the instructions and the replies and I still can`t code it.