UnhandledPromiseRejectionWarning:TypeError:将圆形结构转换为JSON.stringify(<anonymous>)的JSON

时间:2019-05-08 06:23:23

标签: javascript node.js express axios stringify

仅凭本教程Building A Telegram Bot With NodeJS,就可以按发布的方式进行操作。但是从终端

收到了此错误
    (node:20947) UnhandledPromiseRejectionWarning: TypeError: Converting circular structure to JSON
    --> starting at object with constructor 'ClientRequest'
    |     property 'socket' -> object with constructor 'TLSSocket'
    --- property '_httpMessage' closes the circle
    at JSON.stringify (<anonymous>)
    at stringify (/Users/Johnlee/dev/NodeJS/node_modules/express/lib/response.js:1119:12)
    at ServerResponse.json (/Users/Johnlee/dev/NodeJS/node_modules/express/lib/response.js:260:14)
    at ServerResponse.send (/Users/Johnlee/dev/NodeJS/node_modules/express/lib/response.js:158:21)
    at /Users/Johnlee/dev/NodeJS/index.js:29:25
    at processTicksAndRejections (internal/process/task_queues.js:89:5)
(node:20947) 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: 2)
(node:20947) [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.

四处搜寻后,很多人遇到了它,但是我自己找不到解决方案。这是我的节点版本和npm信息。
节点v12.1.0和npm 6.9.0

vim package.json

{
  "name": "nodejs",
  "version": "1.0.0",
  "description": "", 
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },  
  "author": "", 
  "license": "ISC",
  "dependencies": {
    "axios": "^0.18.0",
    "body-parser": "^1.19.0",
    "express": "^4.16.4"
  }
} 

先谢谢您。

0 个答案:

没有答案