Registry / api-client / common-axios

common-axios

JSON →
library0.5.2jsnpmunverified

A lightweight wrapper around axios (v0.21.4) that integrates response message prompts via the web-message library (v0.0.9) and provides request debouncing. The current version is 0.5.2, with no clear release cadence. It adds a config extension to axios for debouncing, data key extraction, and global request/response callbacks. Ships TypeScript types. Primarily for browser environments with UI component libraries that support web-message.

npm install common-axios
INSTALL
IMPORT
SIG · COMMON-AXIOS
C
common-axios
api-clientjavascriptv0.5.2
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.

createAxios
import { createAxios } from 'common-axios'
import createAxios from 'common-axios'
Named export, not default. ESM only; no CJS support.
WebMessageAxiosRequestConfig (type)
import type { WebMessageAxiosRequestConfig } from 'common-axios'
import { WebMessageAxiosRequestConfig } from 'common-axios' in runtime code
TypeScript type only, not a value. Use 'import type' to avoid runtime errors.
createAxios (CommonJS)
const { createAxios } = require('common-axios')
const createAxios = require('common-axios')
CommonJS works, but must destructure the named export.

Creates an Axios instance with debouncing, custom data key extraction, and web-message integration.

import { createAxios } from 'common-axios'; const instance = createAxios({ baseURL: 'https://api.example.com', timeout: 10000, // Common-axios extensions: axiosDebounce: true, dataKey: 'data', messageDuration: 3000, messagePosition: 'center', messageHoverStop: true, axiosResponseCallback: (response) => { console.log('Response intercepted:', response); }, axiosRequestCallback: (config) => { console.log('Request:', config); } }); // Usage instance.get('/users').then(res => console.log(res.data)); // Error messages will appear via web-message automatically
Debug
Known issues
breakingIn v0.3.0, the exported function name changed from 'createAxiosInstance' to 'createAxios'
fix
Replace 'createAxiosInstance' with 'createAxios' in imports.
affects: >=0.1.0 <0.3.0
deprecatedThe 'messageHoverStop' option is deprecated in v0.5.0 and will be removed in v1.0.0. Use 'messagePauseOnHover' instead.
fix
Rename 'messageHoverStop' to 'messagePauseOnHover' in config.
affects: >=0.5.0
gotchaThe library requires both 'axios' and 'web-message' as peer dependencies; if 'web-message' is not installed, message popups will silently fail.
fix
Run 'npm install axios@^0.21.4 web-message@0.0.9' to install peer dependencies.
affects: >=0.1.0
gotchaThe 'dataKey' config expects a dot-notation string (e.g., 'data.result'). If set incorrectly, the response data may be undefined.
fix
Ensure 'dataKey' matches the actual nested path in your API response.
affects: >=0.1.0
Errors
Common errors & fixes
Module not found: Error: Can't resolve 'web-message'
Missing peer dependency 'web-message'
fix
Install it: npm install web-message@0.0.9
TypeError: createAxios is not a function
Incorrect import: default import instead of named export
fix
Use: import { createAxios } from 'common-axios'
Cannot read properties of undefined (reading 'message')
web-message not initialized or not available
fix
Import web-message before using common-axios: import 'web-message'
Property 'axiosDebounce' does not exist on type 'AxiosRequestConfig'
TypeScript error due to missing type definition for extended config
fix
Use the provided 'WebMessageAxiosRequestConfig' type from 'common-axios'
Upgrade
Version history
0.5.2latest on npm
Audit
Dependencies
axiosrequiredpeer dependency for HTTP requests
web-messagerequiredpeer dependency for message popups
Agent activity
36 hits · last 30 days
node
32
Resources
common-axios — npm install common-axios · libregistry