
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
react-auto-axios
Advanced tools
独立的 HTTP 请求工具包,基于 axios 封装,支持拦截器、错误处理、通知等功能。
npm install react-auto-axios
# 或
yarn add react-auto-axios
# 或
pnpm add react-auto-axios
import { RequestClient } from 'react-auto-axios';
// 创建请求客户端
const client = new RequestClient({
baseURL: 'https://api.example.com',
timeout: 30000,
});
// GET 请求
const users = await client.get('/api/users', { page: 1, limit: 10 });
// POST 请求
const result = await client.post('/api/users', {
name: 'John',
email: 'john@example.com',
});
import { RequestClient } from 'react-auto-axios';
const client = new RequestClient({
baseURL: 'https://api.example.com',
});
// 设置通知处理器
client.setNotificationHandler({
showNotification: (type, message, code) => {
// 你的通知逻辑,比如使用 toast、snackbar 等
console.log(type, message, code);
},
});
// 设置存储处理器(用于获取 token 等)
client.setStorageHandler({
get: (key) => {
return localStorage.getItem(key);
},
set: (key, value) => {
localStorage.setItem(key, value);
},
});
// 设置语言处理器
client.setLanguageHandler({
getLang: () => {
return localStorage.getItem('language') || 'en';
},
});
import { initRequestClient, get, post } from 'react-auto-axios';
// 初始化默认实例
initRequestClient({
baseURL: 'https://api.example.com',
});
// 直接使用便捷方法
const users = await get('/api/users');
const result = await post('/api/users', { name: 'John' });
const formData = new FormData();
formData.append('file', file);
const result = await client.post(
'/api/upload',
formData,
{ contentType: 1, responseType: 0 } // multipart/form-data
);
const result = await client.post(
'/api/download',
{ fileId: '123' },
{ contentType: 0, responseType: 3 } // blob
);
// result 是完整的 response 对象
const blob = result.data;
const url = window.URL.createObjectURL(blob);
const a = document.createElement('a');
a.href = url;
a.download = 'file.pdf';
a.click();
new RequestClient(config?: RequestConfig)
get(url: string, params?: any, args?: PostArgs): Promise<any>post(url: string, data: any, reqType?: RequestType, args?: PostArgs): Promise<any>setNotificationHandler(handler: NotificationHandler): voidsetStorageHandler(handler: StorageHandler): voidsetLanguageHandler(handler: LanguageHandler): voidsetErrorMessage(message: string): voidgetInstance(): AxiosInstance - 获取底层 axios 实例initRequestClient(config?: RequestConfig): RequestClientgetRequestClient(): RequestClientget(url: string, params?: any, args?: PostArgs): Promise<any>post(url: string, data: any, reqType?: RequestType, args?: PostArgs): Promise<any>interface RequestConfig {
baseURL?: string;
timeout?: number;
withCredentials?: boolean;
headers?: Record<string, any>;
}
interface RequestType {
contentType?: number; // 0: application/json, 1: multipart/form-data
responseType?: number; // 0: json, 1: text, 2: arraybuffer, 3: blob
}
interface NotificationHandler {
showNotification: (type: 'success' | 'error' | 'warning', message: string, code?: string | number) => void;
}
interface StorageHandler {
get: (key: string) => any;
set: (key: string, value: any) => void;
}
interface LanguageHandler {
getLang: () => string;
}
MIT
FAQs
HTTP request utility for React applications with Material-UI
We found that react-auto-axios demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.