{"id":501,"hash":"b9dc050f1d5570c3e3c7e1168647e3014bb8a388004468801a9aeecb00e81573","pattern":"TypeError: Converting circular structure to JSON --&gt; starting at object with constructor &#39;ClientRequest&#39;","full_message":"I am a nest.js beginner and I am trying to implement Axios with my code and this error occurs and I would like to fix it.\n\n    --> starting at object with constructor 'ClientRequest'\n    |     property 'socket' -> object with constructor 'Socket'\n    --- property '_httpMessage' closes the circle +188941ms\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 (D:\\CUSportcomplex-register\\sso-reg\\node_modules\\express\\lib\\response.js:1123:12)\n    at ServerResponse.json (D:\\CUSportcomplex-register\\sso-reg\\node_modules\\express\\lib\\response.js:260:14)\n    at ExpressAdapter.reply (D:\\CUSportcomplex-register\\sso-reg\\node_modules\\@nestjs\\platform-express\\adapters\\express-adapter.js:24:57)\n    at RouterResponseController.apply (D:\\CUSportcomplex-register\\sso-reg\\node_modules\\@nestjs\\core\\router\\router-response-controller.js:13:36)\n    at D:\\CUSportcomplex-register\\sso-reg\\node_modules\\@nestjs\\core\\router\\router-execution-context.js:173:48\n    at processTicksAndRejections (internal/process/task_queues.js:93:5)\n    at async D:\\CUSportcomplex-register\\sso-reg\\node_modules\\@nestjs\\core\\router\\router-execution-context.js:47:13\n    at async D:\\CUSportcomplex-register\\sso-reg\\node_modules\\@nestjs\\core\\router\\router-proxy.js:9:17\n\nThis is my app.service.ts\n\nasync validateSSO(appticket): Promise<SsoContent> {\n        let instance = axios.create({\n            baseURL: \"http://localhost:8080/\",\n            headers: {\n                'DeeAppId': config.DeeAppId,\n                'DeeAppSecret': config.DeeAppSecret,\n                'DeeTicket': appticket\n            }\n        });\n        instance.get(\"/serviceValidation\")\n            .then(response => {\n                this.ssoContent = response;\n            })\n            .catch(error => {\n                return (error);\n            });\n\n        return this.ssoContent;\n\n    }\n\nand this is my app.controller.ts\n\n    @Get('validation/:appticket')\n    async validateSSO(\n        @Param('appticket') appticket: string\n        //DeeAppTicket is sented via Front-end\n    ): Promise<SsoContent> {\n        return this.registeringService.validateSSO(appticket);\n    }\n\nThank you for your help :)","ecosystem":"npm","package_name":"typescript","package_version":null,"solution":"First of all nest.js provides you HttpService out of the box that you may inject it through DI:\nhttps://docs.nestjs.com/techniques/http-module\n\nSecond - you are trying to store whole response object which is complex data structure and contains circular dependencies as it stated in error message (TypeError: Converting circular structure to JSON)\n\nWhat you should do is either you map the data you need instead of storing whole circular object,\n\nor you should look up to some libs that could parse circular json: https://www.npmjs.com/package/flatted","confidence":0.95,"source":"stackoverflow","source_url":"https://stackoverflow.com/questions/64735881/typeerror-converting-circular-structure-to-json-starting-at-object-with-con","votes":91,"created_at":"2026-04-19T04:51:16.269521+00:00","updated_at":"2026-04-19T04:51:33.563118+00:00"}