D
D
dark_king_132019-12-04 21:49:03
MongoDB
dark_king_13, 2019-12-04 21:49:03

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
5de7febc0eabe622870459.png
This happens when json is sent from Postman to the node.js server.
At the same time, data is entered into the MongoDB database
5de7ff16460ff888211255.png
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

1 answer(s)
A
Andrew Hecc, 2019-12-04
@dark_king_13

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 question

Ask a Question

731 491 924 answers to any question