Answer the question
In order to leave comments, you need to log in
Error sending json to server. How to fix?
Error: UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
This happens when json is sent from Postman to the node.js server.
At the same time, data is entered into the MongoDB database
How to get rid of the error? I don't even understand its meaning.
Answer the question
In order to leave comments, you need to log in
And why on line 23 res.send?
You then send the response through res.json();
Apparently, res.json sets the headers for the response, that json is stored there. And since the answer has already been sent, there is a problem with this.
In general, the error says that you have a promise somewhere without a catch block, I suspect that this line 23 is the problem.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question