Registry / devops / v-axios

v-axios

JSON →
library3.0.9jsnpmunverified

A Vue plugin wrapper for axios that provides a more semantic way to integrate axios into Vue applications, with added features like duplicate request cancellation via cAxios. Current stable version is 3.0.9, supporting Vue 2 and Vue 3 (with v2 and v3 compatible versions). Released monthly, it offers cAxios, get, post, and request helpers, and injects axios into Vue instances as Vue.axios/app.axios and this.$http. Key differentiator: simplifies axios usage in Vue with minimal config and cancel-repeat support, compared to raw axios integration.

npm install v-axios
INSTALL
IMPORT
SIG · V-AXIOS
V
v-axios
devopsjavascriptv3.0.9
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 vAxios from 'v-axios'
const vAxios = require('v-axios'); // Not the Vue plugin usage
Default import is the Vue plugin object; use with Vue.use()
cAxios
import { cAxios } from 'v-axios'
import cAxios from 'v-axios/cAxios'; // Wrong path
Named export for creating get/post/request helpers
axios
import { axios } from 'v-axios'
import axios from 'v-axios'; // That's the default, not axios
Re-exports axios from the axios package; equivalent to import axios from 'axios'

Shows Vue plugin setup with Vue.axios usage and cAxios cancel-repeat feature.

import axios from 'axios'; import vAxios from 'v-axios'; import Vue from 'vue'; Vue.use(vAxios, axios); // Now use Vue.axios or this.$http Vue.axios.get('https://api.example.com/data') .then(response => console.log(response.data)) .catch(error => console.error(error)); // Using cAxios for cancel-repeat import { cAxios } from 'v-axios'; const { get } = cAxios({ cancelRepeat: true }, axios); const getList = get('/api/list'); getList({ page: 1 }).then(data => console.log(data));
Debug
Known issues
gotchaThe default import vAxios is the Vue plugin, not an axios instance. Must use Vue.use() to install.
fix
Use Vue.use(vAxios, axios) or app.use(vAxios, axios) for Vue 3.
affects: >=1.0.0
breakingVersion 2.x dropped support for Vue 2; version 3.x added back support for both Vue 2 and 3.
fix
Use v-axios@3.x if you need Vue 2 support.
affects: 2.x
deprecatedImporting axios from 'v-axios' is deprecated; import directly from 'axios' instead.
fix
Use 'import axios from 'axios'' explicitly.
affects: >=3.0.0
gotchaIn cAxios, if you omit the axios parameter, it uses an internal axios which may differ version from your project's axios.
fix
Always pass your own axios instance: cAxios(config, axios).
affects: >=1.0.0
Errors
Common errors & fixes
Error: Must be called after app.use(vAxios)
Using Vue.axios before calling app.use() in Vue 3.
fix
Ensure app.use(vAxios, axios) is called before accessing Vue.axios.
TypeError: vAxios is not a function
Importing vAxios and trying to use it as a function instead of with Vue.use().
fix
Use Vue.use(vAxios) or app.use(vAxios) instead of vAxios().
Cannot find module 'axios'
axios is a peer dependency and must be installed separately.
fix
Run 'npm install axios v-axios --save' or add axios to your project.
Upgrade
Version history
3.0.9latest on npm
Audit
Dependencies
axiosrequiredPeer dependency – v-axios wraps axios; must be installed separately
Agent activity
4 hits · last 30 days
node
4
Resources