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

Show axios error reason with JSON #665

Merged
merged 1 commit into from
Mar 21, 2023
Merged

Show axios error reason with JSON #665

merged 1 commit into from
Mar 21, 2023

Conversation

BryceStevenWilley
Copy link
Collaborator

I didn't notice until trying to debug some Axios responses that were running with #662, but for some reason, axios doesn't include error.response.data, the attribute that says why the API call failed (on docassemble at least) in error.toJSON().

This change adds it back in the returned JS object manually, additionally optional chaining to make sure that it doesn't crash if error.response isn't present for some reason. Optional chaining is supported in Node 14 and above, which we are on.

I didn't notice until trying to debug some Axios responses, but for some
reason, axios doesn't include `error.response.data`, the attribute that
says why the API call failed (on docassemble at least) in `error.toJSON()`.

This change adds it back in the returned JS object manually, additionally
optional chaining to make sure that it doesn't crash if `error.response`
isn't present for some reason. Optional chaining is supported in Node 14
and above, which we are on.
Copy link
Collaborator

@plocket plocket left a comment

Choose a reason for hiding this comment

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

Great! Thanks! Pls move to v5 or do another PR for v5

@BryceStevenWilley
Copy link
Collaborator Author

v5 PR is #670

@BryceStevenWilley BryceStevenWilley merged commit 1ded185 into v4 Mar 21, 2023
@BryceStevenWilley BryceStevenWilley deleted the better_axios branch March 21, 2023 17:35
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.

2 participants