arthurfiorette / axios-cache-interceptor

📬 Small and efficient cache interceptor for axios. Etag, Cache-Control, TTL, HTTP headers and more!

Home Page:https://axios-cache-interceptor.js.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Handle when the response is a non-axios error.

arthurfiorette opened this issue · comments

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.

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

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

Implemented by 929054e