Registry / devops / auto-axios

auto-axios

JSON →
library1.0.3jsnpmunverified

A TypeScript wrapper for Axios that provides configuration-driven HTTP request management. Version 1.0.3 offers features like request deduplication, automatic empty-parameter handling, configurable error messages and loading masks, and session expiry handling. It differs from raw Axios by providing a declarative configuration approach with extensive TypeScript types, making it suitable for enterprise applications needing centralized HTTP request control. Release cadence is unknown.

npm install auto-axios
INSTALL
IMPORT
SIG · AUTO-AXIOS
A
auto-axios
devopsjavascriptv1.0.3
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

default
import autoAxios from 'auto-axios'
const autoAxios = require('auto-axios')
Package is ESM-only; CommonJS require will break.
IAutoRequestCfg
import type { IAutoRequestCfg } from 'auto-axios'
Type import for configuration interface.
ILoad
import type { ILoad } from 'auto-axios'
Type import for load mask service interface.

Initializes auto-axios with a configuration object and makes a GET request.

import autoAxios from 'auto-axios'; import type { IAutoRequestCfg } from 'auto-axios'; const config: IAutoRequestCfg = { REQ_CONST: { BaseUrl: 'https://api.example.com', LoginExpiredCode: [401, 403], RetSucCode: [0], LoginUrl: '/auth/login', Timeout: 10000, DefaultLang: 'en', MaskClassNames: ['mask'], }, REQ_SWITCH: { GetErrMsgWay: 'byRes', GlobalErrMsgSwitch: 1, GlobalLoadingSwitch: 1, IfCancelDupReq: 1, }, RET_FIELDS_CFG: { RetCode: 'code', RetMsg: 'msg', RetData: 'data', RetCount: 'count', TokenStorageKey: 'token', TokenHttpKey: 'Authorization', LangStorageKey: 'lang', LangHttpKey: 'lang', }, REQ_WAYS_CFG: { DefaultWay: 'post', DefaultHeader: { 'X-Requested-With': 'XMLHttpRequest' }, }, showTipBox: (retMsg, retCode, statusCode, response) => { alert(retMsg); }, }; const api = autoAxios(config); api.request({ url: '/data', method: 'GET' }) .then(response => console.log(response)) .catch(error => console.error(error));
Debug
Known issues
gotchaThe package is ESM-only; using require() will fail with a Module not found error.
fix
Use import statements instead of require().
affects: >=1.0.0
gotchaConfiguration interface IAutoRequestCfg is extensive; missing required fields may cause unexpected behavior.
fix
Ensure all fields in REQ_CONST and RET_FIELDS_CFG are provided.
affects: >=1.0.0
gotchaThe request deduplication feature (IfCancelDupReq) may cancel requests with identical URLs and parameters. This can be surprising if you expect multiple concurrent identical requests.
fix
Set IfCancelDupReq to 0 to disable deduplication.
affects: >=1.0.0
Errors
Common errors & fixes
Cannot find module 'auto-axios'
Using CommonJS require() with an ESM-only package.
fix
Change to import autoAxios from 'auto-axios' and ensure tsconfig has "module": "ESNext" or similar.
TypeError: autoAxios is not a function
Importing the default export incorrectly (e.g., import { autoAxios } instead of import autoAxios).
fix
Use default import: import autoAxios from 'auto-axios'.
Property 'request' does not exist on type '...'
Calling methods on an incorrectly initialized instance.
fix
Ensure you call autoAxios(config) to get the API instance, then use .request() on that instance.
Upgrade
Version history
1.0.3latest on npm
Audit
Dependencies
axiosrequiredunderlying HTTP client
Agent activity
8 hits · last 30 days
node
6
Amazon
1
OpenAI (training)
1
Resources
auto-axios — npm install auto-axios · libregistry