Skip to content

Docs should clarify that Axios instances are callable functions #252

Open
@theo-sim-dev

Description

@theo-sim-dev

Is your feature request related to a problem? Please describe.
This issue was originally reported on axios/axios#6846. Report the same issue here with more clarification as it was originally reported on axios

The main Axios documentation does not currently mention that an Axios instance is itself a callable function — i.e., you can invoke it with a full config object like instance(config) in addition to using convenience methods like instance.get() or instance.post().

This behavior is very useful in real-world use cases like retry logic, where we may not know the original HTTP method, but still want to reuse the full config object after a failure (e.g., token refresh).

const api = axios.create({ baseURL: '/api' });

// Works just like axios(config)
api({
  url: '/users',
  method: 'get',
});

Describe the solution you'd like
Please update the Instance documentation to explicitly mention that Axios instances can be invoked directly with a config object.
A short code example and explanation under a new section like “Calling the instance with a config object” would be helpful.

Describe alternatives you've considered
While it’s possible for developers to discover this behavior through reading the source code or trial and error, that approach is unreliable and creates unnecessary friction. Another workaround is to rewrite retry logic using the method-specific calls (e.g. instance.get(...)), but this requires manually tracking the original HTTP method, headers, and other config fields, which error.config already provides in full.

Clearly documenting the callable nature of Axios instances avoids this redundancy and makes retry implementations more robust and maintainable.

Additional context
This usage pattern is common in libraries like axios-token-manager, which rely on it for re-sending failed requests after refreshing access tokens.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions