I'm using Blocktrail's API, in order to manage bitcoin wallets. The API returns a wallet object, which I guess has circular references contained within.
I want to store the decrypted wallet in the user's session, so that the user doesn't have to enter their password again, but whenever I try to do something like this (wallet
being the wallet object returned by the API):
req.session.wallet = wallet;
I get:
TypeError: Converting circular structure to JSON
at Object.stringify (native)
at MemoryStore.set
So, if an object has a circular structure, is there a way to store a reference to it in a session? Why does this happen?