Axios Interceptor Scope and Instance Isolation Limits
0 reputation · 01 Sept 2023, 06:57 UTC
Axios provides the interceptors object to allow custom logic for request and response transformations. While global interceptors applied to the main axios instance affect all requests, the axios.create() method allows for the creation of isolated instances with their own interceptor stacks.
A design uncertainty arises when managing shared logic across multiple custom instances. If a set of common interceptors is required for several instances but specific instances need unique overrides or a different execution order, the current architecture requires manual registration for each instance.
- How does Axios handle the propagation of global interceptors to instances created via
axios.create()? - Is there a documented mechanism to inherit or share an interceptor stack between separate instances without duplicating the registration logic?