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

Handle when the response is a non-axios error. #609

Closed
arthurfiorette opened this issue Jul 18, 2023 · 3 comments
Closed

Handle when the response is a non-axios error. #609

arthurfiorette opened this issue Jul 18, 2023 · 3 comments
Assignees
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed

Comments

@arthurfiorette
Copy link
Owner

If you have used axios-cache-interceptor before, you probably have seen this error:

TypeError: Cannot read properties of undefined (reading 'id')

This happens because we blindly trust that the rejected response interceptor will be called with a axios error object, which not always is right.

const config = error.config as CacheRequestConfig & { headers: AxiosResponseHeaders };

We should do a try catch in the first line to just propagate non-axios errors.

@arthurfiorette arthurfiorette added enhancement New feature or request help wanted Extra attention is needed good first issue Good for newcomers labels Jul 18, 2023
@arthurfiorette arthurfiorette self-assigned this Jul 18, 2023
@Vayras
Copy link

Vayras commented Jul 19, 2023

Hi @arthurfiorette I would like to work on this issue , can you please tell me how to replicate this issue , I have been working with React and Javascript and we use axios for our api calls, I do understand the problem and I think I can contribute on this

@Vayras
Copy link

Vayras commented Jul 19, 2023

@arthurfiorette I have created a pull request for the same issue let me know the feedback

@arthurfiorette arthurfiorette linked a pull request Jul 19, 2023 that will close this issue
@arthurfiorette
Copy link
Owner Author

Implemented by 929054e

arthurfiorette added a commit that referenced this issue Jul 30, 2023
…and other objects (#616)

* refactor: change id generation location

* fix: lint

* refactor: ensures id will be created only if cache is not false

* chore(deps-dev): bump vitepress from 1.0.0-beta.5 to 1.0.0-beta.6 (#618)

* chore(deps-dev): bump @types/node from 18.16.19 to 18.17.0 (#617)

* chore(deps-dev): bump tslib from 2.6.0 to 2.6.1 (#619)

* chore(deps-dev): bump @types/node from 18.17.0 to 18.17.1 (#620)

* chore: dependabot

* ci: dependabot

* feat: handle non axios errors rejections (#609)

* fix: correct config re throw

* chore(deps-dev): bump eslint-config-prettier from 8.8.0 to 8.9.0 (#624)

* chore(deps-dev): bump jest from 29.6.1 to 29.6.2 (#622)

* feat: turn most types into interfaces (#615)

* Turn most types into interfaces

* Turn 'CacheAxiosResponse' into a interface

* Update docs

* Change docs to be more didactic

* chore(deps-dev): bump jest-environment-jsdom from 29.6.1 to 29.6.2 (#623)

* chore: removed unused eslint comment

* feat: handle errors on object-code

* feat: bring back ids

* chore: lint

---------

Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
Co-authored-by: Arthur Fiorette <arthur.fiorette@gmail.com>
Co-authored-by: Denis Rossati <denis.rossatiramos@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request good first issue Good for newcomers help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants