Skip to content
Advertisement

Cannot set headers after they are sent to the client error nodejs error

When I am trying to post login data in Postman I get an error Cannot set headers after they are sent to the client.

JavaScript

Error Scr

I’ve tried to put process.env.SEC_KEY in this file but it doesn’t work

Advertisement

Answer

It seems that you’re trying to send response twice:

JavaScript

Also you’re using response imported form the express. I’m not sure why you need it, but you probably should use the existing res instead.

All in all, I believe that the solution you’re looking for is this:

JavaScript

Good luck 🙂

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement