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 (v5) #670

Merged
merged 2 commits into from
Mar 21, 2023
Merged

Conversation

BryceStevenWilley
Copy link
Collaborator

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.

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.
@BryceStevenWilley BryceStevenWilley merged commit ebe842b into v5 Mar 21, 2023
@BryceStevenWilley BryceStevenWilley deleted the better_axios_v5 branch March 21, 2023 21:36
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