twilio-node: TypeError: Converting circular structure to JSON
Version: 3.8.1
Code Snippet
const twilio = new Twilio(creds.accountSid, creds.authToken);
const chatClient = twilio.chat.services(creds.chatServiceSid);
// ....
JSON.stringify(chatClient.channels(id).fetch())
Exception/Log
TypeError: Converting circular structure to JSON
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 7
- Comments: 18 (7 by maintainers)
I’ve created a ticket internally to evaluate the different options and implement one so we should hopefully get to this in the near future.
A
toJSON
method has been added to all instance objects in3.13.0
. Thank you all for your patience.I’ve created this PR which should solve this issue, would appreciate any feedback you all have.
https://github.com/twilio/twilio-node/pull/325
For now I’ve written this utility that removes some of the keys (that I anyways didn’t really want) and that removes all the circular references.
I think there should be an options object that we could pass while instantiating twilio which could remove these references for us.