MongoDB // Nodemon在邮递员POST中崩溃

问题描述 投票:-1回答:2

当我运行nodemon file.js时,显示此内容(cmd):

(node:23816) DeprecationWarning: current URL string parser is deprecated, and will be removed in a future version. To use the new parser, pass option { useNewUrlParser: true } to MongoClient.connect.
(node:23816) DeprecationWarning: current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version. To use the new Server Discover and Monitoring engine, pass option { useUnifiedTopology: true } to the MongoClient constructor.

And then when i POST in Postman show this (cmd) : 
events.js:287
      throw er; // Unhandled 'error' event
      ^

ReferenceError: response is not defined
    at D:\Desktop\swag-shop-api\server.js:21:7
    at D:\Desktop\swag-shop-api\node_modules\mongoose\lib\model.js:4889:16
    at D:\Desktop\swag-shop-api\node_modules\mongoose\lib\helpers\promiseOrCallback.js:24:16
    at D:\Desktop\swag-shop-api\node_modules\mongoose\lib\model.js:4912:21
    at model.<anonymous> (D:\Desktop\swag-shop-api\node_modules\mongoose\lib\model.js:493:7)
    at D:\Desktop\swag-shop-api\node_modules\kareem\index.js:315:21
    at next (D:\Desktop\swag-shop-api\node_modules\kareem\index.js:209:27)
    at D:\Desktop\swag-shop-api\node_modules\kareem\index.js:182:9
    at D:\Desktop\swag-shop-api\node_modules\kareem\index.js:507:38
    at processTicksAndRejections (internal/process/task_queues.js:79:11)
Emitted 'error' event on Function instance at:
    at D:\Desktop\swag-shop-api\node_modules\mongoose\lib\model.js:4891:13
    at D:\Desktop\swag-shop-api\node_modules\mongoose\lib\helpers\promiseOrCallback.js:24:16
    [... lines matching original stack trace ...]
    at processTicksAndRejections (internal/process/task_queues.js:79:11)
[nodemon] app crashed - waiting for file changes before starting...

但是当我执行db.products.find({})时,它显示了我从邮递员发布的所有内容>>

请有人可以帮助我...

server.js file:

当我运行nodemon file.js时,它显示以下内容(cmd):(node:23816)DeprecationWarning:不建议使用当前的URL字符串解析器,并将在以后的版本中将其删除。要使用新的解析器,请传递选项{...

javascript node.js mongodb postman nodemon
2个回答
0
投票

如果您需要一些指导以在mongodb中的集合中列出您的文档,只需将此代码用作起点:


0
投票

解决方案:

© www.soinside.com 2019 - 2024. All rights reserved.