I am using Node.js and Express . when i try to access
the API at
http://localhost:5000/api/users, then i received the following error. I know that the code is related to mongodb:
Connected to MongoDB..... (node:25404) UnhandledPromiseRejectionWarning: Error [ERR_HTTP_HEADERS_SENT]: Cannot set headers after they are sent to the client at ServerResponse.setHeader (_http_outgoing.js:482:11) at ServerResponse.header (/Users/Sadiqoptimum/Desktop/vidly/node_modules/express/lib/response.js:767:10) at route.post (/Users/Sadiqoptimum/Desktop/vidly/routes/users.js:23:9) (node:25404) 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(). (rejection id: 1) (node:25404) [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.