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

Use it with an existing axios instance #77

Open
gagagast opened this issue Jul 18, 2021 · 2 comments
Open

Use it with an existing axios instance #77

gagagast opened this issue Jul 18, 2021 · 2 comments
Labels
enhancement New feature or request

Comments

@gagagast
Copy link

Hello,
I try to use this tool in an existing app. It already uses an axios instance in JWTService Class to handle auth.
Is there a way to use the existing axios instance in the openApiClient instance rather than create a new one.

Thx

@anttiviljami
Copy link
Member

That's a cool idea. PRs accepted :)

@anttiviljami anttiviljami added the enhancement New feature or request label Aug 10, 2021
@npdev453
Copy link
Contributor

npdev453 commented Jan 6, 2022

I check this idea and what can I say:

  1. AxiosInstance does not have .create method for creating sub-instances
    Axios sub-instances axios/axios#1170
    Adding feature to support axios sub-instances axios/axios#2040

  2. We can't use provided AxiosInstance without sub-instancing or cloning, it looks like antipattern with side effects to unexpected modifying provided object.

  3. Seems like defaultAxiosConfigs will not usable together with instance and constructor type will be like

 { ... } & ({
    axiosConfigDefaults?: AxiosRequestConfig;
    baseAxiosInstance?: never;
  } | {
    axiosConfigDefaults?: never;
    baseAxiosInstance?: AxiosInstance;
  })

@anttiviljami, @gagagast
Maybe you can help me to found a nice solution for 1 and 2 list items.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

3 participants