When using the Axios library in TypeScript, it is important to follow consistent naming conventions to improve code readability and maintainability. Specifically:
onUploadProgress
and onDownloadProgress
.responseEncoding
and responseType
.Following these practices will help developers working on your Axios-based code understand the purpose and usage of your API more intuitively. Provide clear, well-named Axios-related functionality to improve the developer experience.
Example:
// ✅ Good - Clear event handler naming with "on" prefix
const config: AxiosRequestConfig = {
onUploadProgress: (progressEvent: ProgressEvent) => { /* ... */ },
onDownloadProgress: (progressEvent: ProgressEvent) => { /* ... */ }
}
// ❌ Bad - Unclear purpose of the function
const config: AxiosRequestConfig = {
uploadProgress: (progressEvent: ProgressEvent) => { /* ... */ },
downloadProgress: (progressEvent: ProgressEvent) => { /* ... */ }
}
// ✅ Good - Consistent parameter structure and clear scope
const config: AxiosRequestConfig = {
responseEncoding: 'utf-8',
proxy: {
auth: { username: 'mikeymike', password: 'rapunz3l' } // Matches other auth patterns
}
}
Enter the URL of a public GitHub repository