Basic Node and Express - Use the .env File get error Cannot set headers after they are sent to the client

I got a strange error in this problem made me crazy i don’t know what is the reason for this error



and this is my code

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

this code works fine and give no error when i run it on glitch but when i click submit button in freecodecamp this error apears to me.

1 Like

If your test case is passed then let me know .
because i also stuck here

Hello there,

There appears to have been some breaking change between a package the fCC tests use, and Glitch.

For now, the recommended steps are:

  1. Fork the repo to another platform, like CodeSandbox, and complete it there.
  2. Move on from this lesson, as most of the other tests do not rely on the broken package.

Hope this helps

1 Like

thanks for your helping i will fork the repo in another platform

i use repil.it it awesome and super fast to

1 Like

Your Test cases is passed ?

yup, i just finish this module easily after moving to repl :grinning:

1 Like

Hey Well-done
Good Job
Let me know what is step are you did ?
Can you please tell me how to use repil it to complete this Challange…

Thank you so much dear .
You Reply give me a gift today on my birthday.
Really this Challange is frustrating.
Once again Thank you🤗

Happy birthday :heart_eyes:
look after signed in repl.it you will find button at the top right corner called new repl after that choose import from github like this
Untitled

and add the link of the official repo link

1 Like

Thank You So much dear :heart_eyes:

1 Like

Its giving me error

Hello @akkiee11,

It looks like you need to run npm i within the console.

2 Likes

Yes Its Working But Not passed test cases


Screenshot from 2020-06-19 02-04-15

In the second case if MESSAGE_STYLE not equal to uppercase it should be
Hello json instead of hello json with upper case for the first character only

1 Like

Yes Its Right…
Its Working.