Node js environment variable help?

Anybody explain me “this” tutorial in easy way.

My project link.

" Store the variable MESSAGE_STYLE=uppercase in the .env file. Then tell the GET /json route handler that you created in the last challenge to transform the response object’s message to uppercase if process.env.MESSAGE_STYLE equals uppercase . The response object should become {"message": "HELLO JSON"} "

explanation is given in the instruction page. However, you need to create a new file, while creating the file- name it .env

Then you need to store the required variable in it as mentioned there
“Store the variable MESSAGE_STYLE=uppercase in the .env file.”

Then in the myApp.js you should follow the logic as mentioned .

It still gives me this error.

@priyanshushrama709, your code is correct, and it’s working fine.
This test had an issue, and it seems still not fixed, so test is not passing.
Since your code is ok, now (1) you can read this all and find an alternative solution from here

or (2) you can skip this test and move to the next challenges

I was pass the test with this method

app.get("/json", (req, res) => {
  let response = { message: "Hello json" };
  if (process.env.MESSAGE_STYLE === "uppercase") {
    response.message = response.message.toUpperCase();

It works fine they accept it.

1 Like