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

Set config instance when calling attach #121

Open
sk- opened this issue Aug 19, 2020 · 3 comments
Open

Set config instance when calling attach #121

sk- opened this issue Aug 19, 2020 · 3 comments

Comments

@sk-
Copy link

sk- commented Aug 19, 2020

The raxConfig requires an instance field, which if not set will default to the default axios instance, however that's not what one wants when attaching it to a non-default instance.

This is awkward an error prone, as one would need to create the object as follows:

const axiosInstance = axios.create({
  raxConfig: {
    retryDelay: 10000,
    backoffType: 'static',
  },
});
axiosInstance.defaults.raxConfig = {...axiosInstance.defaults.raxConfig, instance: axiosInstance};

Instead, I suggest to modify attach to do something like:

export function attach(instance?: AxiosInstance) {
  if (instance) {
    instance.defaults.raxConfig = {...instance.defaults.raxConfig, instance};
  }
  instance = instance || axios;
  return instance.interceptors.response.use(onFulfilled, onError);
}
@reessm01
Copy link

Yeah, I lost a bit of time figuring out that nuanced detail as I was limited to axios 0.19.2. How active is @JustinBeckwith? I wouldn't mind helping out as I think this library has a great deal of potential.

@JustinBeckwith
Copy link
Owner

👋 I am on GitHub most days for work, but do not actively do much on this library. We ended up going a different direction for our retries & HTTP, so anything I can give here is best effort. I really love well thought out PRs though, and I'd be happy to add maintainers if that makes sense.

@reessm01
Copy link

I've got a feature branch ready whenever you get a chance if you want to add me as a maintainer. Beyond unit testing I'll try out the build in a project I am working on to see if its compatible with axios ~0.19.0.

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

No branches or pull requests

3 participants