我正在使用Node.js和Express。当我尝试访问
http://localhost:5000/api/users
处的API,然后我收到以下错误。我知道代码与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.