openapi-client-axios
openapi-client-axios copied to clipboard
Use it with an existing axios instance
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
That's a cool idea. PRs accepted :)
I check this idea and what can I say:
-
AxiosInstance
does not have.create
method for creating sub-instances https://github.com/axios/axios/issues/1170 https://github.com/axios/axios/pull/2040 -
We can't use provided
AxiosInstance
without sub-instancing or cloning, it looks like antipattern with side effects to unexpected modifying provided object. -
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.