
Security News
Axios Maintainer Confirms Social Engineering Attack Behind npm Compromise
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.
@mints/request
Advanced tools
A lightweight Axios + operation wrapper with global config and toast integration
A lightweight HTTP and operation wrapper built on Axios for React/Vite projects.
Supports global config, toast integration, request context, and clean async operation management.
toast integration (decoupled from UI)operator() helper for async request + loading + error feedbackonUnauthorized() global handler for 401useRequest for automatic requests with cancellationnpm install @mints/request axios
axiosis a peer dependency — please install it in your project.
Call setupRequest() once before using request or operator (e.g. in src/setup.ts or main.tsx):
// setup.ts
import { setupRequest } from '@mints/request';
import { toast } from '@mints/ui'; // your own toast system
setupRequest({
baseURL: '/api',
defaultHeaders: () => ({
Authorization: `Bearer ${localStorage.getItem('token') || ''}`,
}),
toast: {
success: toast.success,
error: toast.error,
},
onUnauthorized: () => {
window.location.href = '/login';
},
});
requestimport { request } from '@mints/request';
const data = await request('/users');
const user = await request('/users/1', {
method: 'put',
data: { name: 'Tom' },
});
operator() wrapperimport { operator, request } from '@mints/request';
const [ok, data] = await operator(() =>
request('/users', { params: { q: 'admin' } }),
);
operator() automatically supports:
setOperating)useRequestImport from the React subpath:
import { useRequest } from '@mints/request/react';
import { request } from '@mints/request';
function Example() {
const { loading, data, error } = useRequest(
(signal) => request('/users', { signal }),
[], // dependency list, re-run when values change
);
if (loading) return <span>Loading...</span>;
if (error) return <span>Failed: {String(error)}</span>;
return <pre>{JSON.stringify(data, null, 2)}</pre>;
}
setupRequest(config: GlobalRequestConfig)Set global request behavior.
type GlobalRequestConfig = {
baseURL?: string;
defaultHeaders?: () => Record<string, string>;
toast?: {
success?: (msg: string) => void;
error?: (msg: string) => void;
};
onUnauthorized?: () => void;
};
request(path: string, config?: AxiosRequestConfig): Promise<any>An enhanced version of Axios request that auto-injects baseURL and headers.
type RequestConfig = AxiosRequestConfig & {
/**
* Skip triggering the global onUnauthorized handler for this request.
*/
skipUnauthorizedHandler?: boolean;
};
operator(fn: () => Promise<T>, config?: OperateConfig): Promise<[boolean, T?, unknown?]>The best practice wrapper for async requests.
type OperateConfig = {
setOperating?: (running: boolean) => void;
formatMessage?: () => string;
formatReason?: (err: unknown) => string;
hideToast?: boolean;
toast?: {
success?: (msg: string) => void;
error?: (msg: string) => void;
};
};
useRequest APIfunction useRequest<T>(
request: (signal: AbortSignal) => Promise<T>,
deps?: React.DependencyList,
): {
loading: boolean;
data?: T;
error?: unknown;
};
loading, data, and error.import { updateRequestConfig } from '@mints/request';
updateRequestConfig({
defaultHeaders: () => ({
Authorization: `Bearer ${newToken}`,
}),
});
setupRequest once in your app entry (e.g. main.tsx, setup.ts).export const getUser = () => request('/user');
export const createUser = (data: any) =>
operator(() => request('/user', { method: 'post', data }));
MIT License © 2025 mints-components
FAQs
A lightweight Axios + operation wrapper with global config and toast integration
The npm package @mints/request receives a total of 1 weekly downloads. As such, @mints/request popularity was classified as not popular.
We found that @mints/request 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
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.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.