As a beginner in nest.js, I am attempting to incorporate Axios into my code. However, I have encountered an error that I would like assistance in resolving.
--> starting at object with constructor 'ClientRequest'
| property 'socket' -> object with constructor 'Socket'
--- property '_httpMessage' closes the circle +188941ms
TypeError: Converting circular structure to JSON
--> starting at object with constructor 'ClientRequest'
| property 'socket' -> object with constructor 'Socket'
--- property '_httpMessage' closes the circle
at JSON.stringify (<anonymous>)
at stringify (D:\CUSportcomplex-register\sso-reg\node_modules\express\lib\response.js:1123:12)
at ServerResponse.json (D:\CUSportcomplex-register\sso-reg\node_modules\express\lib\response.js:260:14)
at ExpressAdapter.reply (D:\CUSportcomplex-register\sso-reg\node_modules\@nestjs\platform-express\adapters\express-adapter.js:24:57)
at RouterResponseController.apply (D:\CUSportcomplex-register\sso-reg\node_modules\@nestjs\core\router\router-response-controller.js:13:36)
at D:\CUSportcomplex-register\sso-reg\node_modules\@nestjs\core\router\router-execution-context.js:173:48
at processTicksAndRejections (internal/process/task_queues.js:93:5)
at async D:\CUSportcomplex-register\sso-reg\node_modules\@nestjs\core\router\router-execution-context.js:47:13
at async D:\CUSportcomplex-register\sso-reg\node_modules\@nestjs\core\router\router-proxy.js:9:17
This is the content of my app.service.ts file:
async validateSSO(appticket): Promise<SsoContent> {
let instance = axios.create({
baseURL: "http://localhost:8080/",
headers: {
'DeeAppId': config.DeeAppId,
'DeeAppSecret': config.DeeAppSecret,
'DeeTicket': appticket
}
});
instance.get("/serviceValidation")
.then(response => {
this.ssoContent = response;
})
.catch(error => {
return (error);
});
return this.ssoContent;
}
Additionally, here is the code from my app.controller.ts file:
@Get('validation/:appticket')
async validateSSO(
@Param('appticket') appticket: string
//DeeAppTicket is sented via Front-end
): Promise<SsoContent> {
return this.registeringService.validateSSO(appticket);
}
Your help in resolving this issue would be greatly appreciated. Thank you :)