-
-
Notifications
You must be signed in to change notification settings - Fork 11.5k
Closed
Description
Description
The documentation would benefit from a comprehensive TypeScript example showing how to create a custom axios instance with properly typed request/response interceptors.
Current Documentation Gap
While the README covers basic usage, TypeScript users often struggle with:
- Properly typing custom axios instances
- Adding type-safe interceptors
- Handling error types in interceptors
Suggested Addition
Add a TypeScript section in the README with an example like:
import axios, { AxiosInstance, InternalAxiosRequestConfig, AxiosResponse } from 'axios';
const apiClient: AxiosInstance = axios.create({
baseURL: 'https://api.example.com',
timeout: 10000,
});
apiClient.interceptors.request.use(
(config: InternalAxiosRequestConfig) => {
// Add auth token
return config;
}
);Benefits
- Reduces common TypeScript errors for new users
- Promotes type-safe API client patterns
- Helps developers using axios in React/Node projects
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels