.env File use json

Tell us what’s happening:
Describe your issue in detail here.
The response of the endpoint

/json

should change according to the environment variable

MESSAGE_STYLE

my code:

app.get("/json", (request, response) => {
  const message = {process.env.MESSAGE_STYLE === 'uppercase') ? 'HELLO JSON' : 'Hello json' ;{
    res.json({ message});
  });

Your project link(s)

solution: Glitch :・゚✧

Your browser information:

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

Challenge: Use the .env File

Link to the challenge:

Does the response change whenever you change the MESSAGE_STYLE environment variable?

It’s not clear to me what you are asking for help with.

It worked on replit but when I upload on the test link to pass it gives the same error

What link did you provide the test? IIRC you need to provide the “preview” link for the tests to work.

sorry it didnt work. my code on glitch is:

app.get("/json", (req, res) => {
  const mySecret = process.env["MESSAGE_STYLE"];
  if (mySecret === "uppercase") {
    response = "HELLO JSON".toUpperCase();
  } else {
    response = "Hello json";
  }
  res.json({ message: response });
});

What is the error message?

It is great that you solved the challenge, but instead of posting your full working solution, it is best to stay focused on answering the original poster’s question(s) and help guide them with hints and suggestions to solve their own issues with the challenge.

We are trying to cut back on the number of spoiler solutions found on the forum and instead focus on helping other campers with their questions and definitely not posting full working solutions.

You can post solutions that invite discussion (like asking how the solution works, or asking about certain parts of the solution). But please don’t just post your solution for the sake of sharing it.
If you post a full passing solution to a challenge and have questions about it, please surround it with [spoiler] and [/spoiler] tags on the line above and below your solution code.

Thenk`s Jeremy I will.
He got a good solution for the Replit editor ,but thing is that that Replit is connected and disconected and you dont see that in the editor …
And if you working ofline you got the err {not found}
then buum …is connected…your work shows right…

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 (’).

Mey I asck a question?
If I hawe err in Glitch and delete dat err ,and write some ader code, save and refresh
my page … whay is my err which I am deleted stil apiers in the page?

You need to post your Glitch link otherwise we can’t help.

But you might want to open your own thread for this question. Also, please try to make the question more clear, I really do not understand what you are asking.

for example you start you code with let…
delet let… and write const…
save and refresh I got the err let is not define?
and I refresh it agen and save ,and it stil stands let is not define …?

and if I change the url in Glich
then he exepts my new code?
Aderwise he repet my err ,which I was deleted…?

I am new to Glitch… and Replit

I have no context for your question. Please post a link to your Glitch which has this error.

If you are saying it’s somehow remembering old code and giving you an error for old code, then I’m not sure why that would be. Again, I have nothing to go on here without an example.

Yes I am seying that he remembers the last err and repets it after you delet it . Thenks …

I don’t know why that would happen and without an example, I can’t say more.

Thenk`s … I cant show you example I change url in Glich and
thet worked…

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