当我尝试使用 axios 向我自己的 typeorm API 发出发布请求时,出现以下错误:
\nTypeError: Converting circular structure to JSON\n --> starting at object with constructor 'ClientRequest'\n | property 'socket' -> object with constructor 'Socket'\n --- property '_httpMessage' closes the circle\n at JSON.stringify (<anonymous>)\n at stringify (C:\\Users\\Usuario\\Documents\\Manga-Api\\Manga-Api\\node_modules\\express\\lib\\response.js:1123:12)\n at ServerResponse.json (C:\\Users\\Usuario\\Documents\\Manga-Api\\Manga-Api\\node_modules\\express\\lib\\response.js:260:14)\n at ServerResponse.send (C:\\Users\\Usuario\\Documents\\Manga-Api\\Manga-Api\\node_modules\\express\\lib\\response.js:158:21)\n at C:\\Users\\Usuario\\Documents\\Manga-Api\\Manga-Api\\src\\managers\\scrape.manager.ts:163:33\n at processTicksAndRejections (node:internal/process/task_queues:93:5)\nRun Code Online (Sandbox Code Playgroud)\n我尝试使用一些库来修复循环结构 JSON 并解析它,但都失败了:
\nconst safeStringify = require('json-stringify-safe');\nconst CircularJSON = require('circular-json');\nRun Code Online (Sandbox Code Playgroud)\n实体的关系都没有添加级联选项。
\nawait axios.post(apiName+'/object', data, { headers: { Authorization: res.req.headers.authorization } }).then(response => { res.send(response); });\n …Run Code Online (Sandbox Code Playgroud)