Registry / devops / wd-axios

wd-axios

JSON →
library6.12.6jsnpmunverified

An axios wrapper library for JavaScript/TypeScript that provides built-in loading indicators, success/error prompts, request caching, request queue deduplication with configurable cancellation, and preloading support. Current stable version is 6.12.6, with active development. It simplifies common patterns like token injection via interceptors and automatic response validation. The library ships with TypeScript type definitions and supports ESM/CJS via module bundlers. Key differentiators include a single function API for all requests, a unified settings object for global defaults, and integration of UI feedback (loading, prompts) directly into the request lifecycle.

npm install wd-axios
INSTALL
IMPORT
SIG · WD-AXIOS
W
wd-axios
devopsjavascriptv6.12.6
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 (wdaxios function)
import wdaxios from 'wd-axios'
const wdaxios = require('wd-axios')
ESM-only export; CommonJS require() may fail depending on bundler
setOptions
import { setOptions } from 'wd-axios'
import setOptions from 'wd-axios'
setOptions is a named export, not default
WdPayload (type)
import type { WdPayload } from 'wd-axios'
TypeScript type import; no runtime value
WdSettings (type)
import type { WdSettings } from 'wd-axios'
import { WdSettings } from 'wd-axios'
WdSettings is a type-only export; use 'import type' to avoid runtime errors

Demonstrates global settings configuration and a basic GET request with cache, response property filtering, and parameter merging.

import wdaxios from 'wd-axios'; import { setOptions } from 'wd-axios'; import type { WdSettings } from 'wd-axios'; const settings: WdSettings = { timeout: 5000, successValidator: (response) => response.data.status === 100, responseCodeAction: { 100: (data, next) => { next(); }, }, }; setOptions(settings); async function fetchData() { try { const response = await wdaxios( { cache: 'abc', props: ['meta'], url: 'http://localhost:5173/abc', params: { a: 1 }, }, { params: { a: 2, b: 2 } } ); console.log(response); } catch (error) { console.error(error); } } fetchData();
Debug
Known issues
gotchaThe default export is a function, but the package also exports named exports (setOptions, types). Mixing default and named imports requires correct ESM syntax.
fix
Use `import wdaxios from 'wd-axios'` for the main function, and `import { setOptions } from 'wd-axios'` for configuration.
affects: *
gotchaThe `cache` option is not a boolean; set to `false` to disable, or a string key to enable. A common mistake is setting `cache: true`, which will be treated as a truthy string key.
fix
Use `cache: false` or `cache: 'myCacheKey'`.
affects: *
breakingIn version 6.x, the `loadingStyles` and `promptStyles` settings are part of `WdSettings`; in earlier versions (<6.0) these were configured differently. Check migration guide if upgrading.
fix
Migrate any custom loading/prompt configuration to the new `loadingStyles` and `promptStyles` properties.
affects: >=6.0
Errors
Common errors & fixes
TypeError: wdaxios is not a function
Incorrect import: using CommonJS require() instead of ESM import.
fix
Change `const wdaxios = require('wd-axios')` to `import wdaxios from 'wd-axios'`.
Uncaught TypeError: Cannot destructure property 'setOptions' of '(intermediate value)' as it is undefined.
Attempted named import from default export incorrectly.
fix
Use `import { setOptions } from 'wd-axios'` instead of `import wdaxios from 'wd-axios'` and then destructuring.
Request failed with status 404
URL path is relative and no base URL is configured; or the endpoint does not exist.
fix
Set a base URL via `setOptions({ baseURL: 'https://api.example.com' })` or provide full URLs in requests.
Upgrade
Version history
6.12.6latest on npm
Audit
Dependencies
axiosrequiredCore HTTP client used for all requests
toastify-jsoptionalUsed for prompt/notification UI (success/error messages)
Agent activity
7 hits · last 30 days
node
6
Resources
wd-axios — npm install wd-axios · libregistry