Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed AxiosError.toJSON method to avoid circular references; #5247

Merged
merged 3 commits into from Nov 22, 2022

Conversation

DigitalBrainJS
Copy link
Collaborator

Copy link
Member

@jasonsaayman jasonsaayman left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome thanks 🚀

@DamianRivas
Copy link

@DigitalBrainJS I noticed you are the original implementer of the toJSON method. I've been wondering, why does this method returns an object instead of a string?

toJSONObject's return type is semantically correct as in the return type is what anyone would expect based on the method name, but I was surprised to learn toJSON's return type isn't stringified.

@DigitalBrainJS
Copy link
Collaborator Author

is what anyone would expect based on the method name

@DamianRivas In fact, no one should expect this, since this is typical behavior for the toJSON method in the context of the JS ecosystem. This method is used to convert an object/model to a JSON object, it does not take care of the final conversion to a JSON string. JSON.stringify should be used for this, which calls it internally.

https://stackoverflow.com/questions/20734894/difference-between-tojson-and-json-stringify

@DamianRivas
Copy link

@DigitalBrainJS I had no idea that was a widely used convention. Thank you for clarifying 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Error.toJSON() should exclude httpsAgent
3 participants