UnhandledPromiseRejectionWarning:
Error [ERR_HTTP_HEADERS_SENT]:
Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:533:11)
(node:1404024) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client
at ServerResponse.setHeader (_http_outgoing.js:533:11)
at ServerResponse.header (C:\Users\ehgks\Desktop\project\test-back\node_modules\express\lib\response.js:771:10)
at ServerResponse.send (C:\Users\ehgks\Desktop\project\test-back\node_modules\express\lib\response.js:170:12)
at ServerResponse.json (C:\Users\ehgks\Desktop\project\test-back\node_modules\express\lib\response.js:267:15)
at C:\Users\ehgks\Desktop\project\test-back\controllers\Users.js:121:28
at processTicksAndRejections (internal/process/task_queues.js:97:5)
(Use `node --trace-warnings ...` to show where the warning was created)
(node:1404024) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:1404024) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated.
In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
DeprecationWarning: Mongoose:
`findOneAndUpdate()` and `findOneAndDelete()`
without the `useFindAndModify` option set to false are deprecated.
If you use Model.findOneAndUpdate(), by default you'll see one of the below deprecation warnings.
Mongoose's findOneAndUpdate() long pre-dates the MongoDB driver's findOneAndUpdate() function, so it uses the MongoDB driver's findAndModify() function instead. You can opt in to using the MongoDB driver's findOneAndUpdate() function using the useFindAndModify global option.
// Make Mongoose use `findOneAndUpdate()`. Note that this option is `true`
// by default, you need to set it to false.
mongoose.set('useFindAndModify', false);
You can also configure useFindAndModify by passing it through the connection options.
mongoose.connect(uri, { useFindAndModify: false });
This option affects the following model and query functions. There are no intentional backwards breaking changes, so you should be able to turn this option on without any code changes. If you discover any issues, please open an issue on GitHub.
Model.findByIdAndDelete()
Model.findByIdAndRemove()
Model.findByIdAndUpdate()
Model.findOneAndDelete()
Model.findOneAndRemove()
Model.findOneAndUpdate()
Query.findOneAndDelete()
Query.findOneAndRemove()
Query.findOneAndUpdate()