Gathering detailed insights and metrics for vue-axios
Gathering detailed insights and metrics for vue-axios
Gathering detailed insights and metrics for vue-axios
Gathering detailed insights and metrics for vue-axios
npm install vue-axios
Typescript
Module System
Node Version
NPM Version
73.8
Supply Chain
96.2
Quality
75.5
Maintenance
100
Vulnerability
100
License
JavaScript (100%)
Verify real, reachable, and deliverable emails with instant MX records, SMTP checks, and disposable email detection.
Total Downloads
28,665,954
Last Day
20,898
Last Week
104,344
Last Month
440,424
Last Year
5,467,224
MIT License
2,013 Stars
206 Commits
182 Forks
42 Watchers
7 Branches
10 Contributors
Updated on Mar 07, 2025
Minified
Minified + Gzipped
Latest Version
3.5.2
Package Id
vue-axios@3.5.2
Unpacked Size
10.81 kB
Size
3.81 kB
File Count
6
NPM Version
6.14.16
Node Version
12.22.12
Cumulative downloads
Total Downloads
Last Day
13.1%
20,898
Compared to previous day
Last Week
9.5%
104,344
Compared to previous week
Last Month
-3.8%
440,424
Compared to previous month
Last Year
-0.9%
5,467,224
Compared to previous year
A small wrapper for integrating axios to Vuejs
I created this library because, in the past, I needed a simple solution to migrate from vue-resource
to axios
.
It only binds axios to the vue
instance so you don't have to import everytime you use axios
.
1npm install --save axios vue-axios
Import libraries in entry file:
1// import Vue from 'vue' // in Vue 2 2import * as Vue from 'vue' // in Vue 3 3import axios from 'axios' 4import VueAxios from 'vue-axios'
Usage in Vue 2:
1Vue.use(VueAxios, axios)
Usage in Vue 3:
1const app = Vue.createApp(...) 2app.use(VueAxios, axios)
Just add 3 scripts in order: vue
, axios
and vue-axios
to your document
.
This wrapper bind axios
to Vue
or this
if you're using single file component.
You can use axios
like this:
1Vue.axios.get(api).then((response) => { 2 console.log(response.data) 3}) 4 5this.axios.get(api).then((response) => { 6 console.log(response.data) 7}) 8 9this.$http.get(api).then((response) => { 10 console.log(response.data) 11})
This wrapper bind axios
to app
instance or this
if you're using single file component.
in option API, you can use axios
like this:
1// App.vue 2export default { 3 name: 'App', 4 methods: { 5 getList() { 6 this.axios.get(api).then((response) => { 7 console.log(response.data) 8 }) 9 // or 10 this.$http.get(api).then((response) => { 11 console.log(response.data) 12 }) 13 } 14 } 15}
however, in composition API setup
we can't use this
, you should use provide
API to share the globally instance properties first, then use inject
API to inject axios
to setup
:
1// main.ts 2import { createApp } from 'vue' 3import App from './App.vue' 4import store from './store' 5import axios from 'axios' 6import VueAxios from 'vue-axios' 7 8const app = createApp(App).use(store) 9app.use(VueAxios, axios) 10app.provide('axios', app.config.globalProperties.axios) // provide 'axios' 11app.mount('#app') 12 13// App.vue 14import { inject } from 'vue' 15 16export default { 17 name: 'Comp', 18 setup() { 19 const axios: any = inject('axios') // inject axios 20 21 const getList = (): void => { 22 axios 23 .get(api) 24 .then((response: { data: any }) => { 25 console.log(response.data) 26 }); 27 }; 28 29 return { getList } 30 } 31}
Please kindly check full documentation of axios too
The library allows to have different version of axios at the same time as well as change the default registration names (e.g. axios
and $http
). To use this feature you need to provide options like an object where:
<key>
is registration name<value>
is instance of axiosFor Vue it looks like this:
1// Vue 2 / Vue 3 + Composition API 2import App from './App.vue' 3import VueAxios from 'vue-axios' 4import axios from 'axios' 5import axios2 from 'axios' 6Vue.use(VueAxios, { $myHttp: axios, axios2: axios2 }) // or app.use() for Vue 3 Optiona API 7 8// usage 9export default { 10 methods: { 11 getList(){ 12 this.$myHttp.get(api).then((response) => { 13 console.log(response.data) 14 }) 15 this.axios2.get(api).then((response) => { 16 console.log(response.data) 17 }) 18 } 19 } 20}
It works similarly in Options API of Vue 3 but if you want to use Composition API you should adjust your code a bit to extract proper keys, e.g.:
1// Vue 2 + Setup function 2import { createApp } from 'vue' 3import App from './App.vue' 4import store from './store' 5import axios from 'axios' 6import VueAxios from 'vue-axios' 7 8const app = createApp(App).use(store) 9app.use(VueAxios, { $myHttp: axios, axios2: axios2 }) 10app.provide('$myHttp', app.config.globalProperties.$myHttp) // provide '$myHttp' 11app.provide('axios2', app.config.globalProperties.axios2) // provide 'axios2' 12app.mount('#app') 13 14// App.vue 15import { inject } from 'vue' 16 17export default { 18 name: 'Comp', 19 setup() { 20 const $myHttp: any = inject('$myHttp') // inject $myHttp 21 22 const getListWithMyHttp = (): void => { 23 $myHttp 24 .get(api) 25 .then((response: { data: any }) => { 26 console.log(response.data) 27 }); 28 }; 29 30 const axios2: any = inject('axios2') // inject axios2 31 const getListWithAxios2 = (): void => { 32 axios2 33 .get(api) 34 .then((response: { data: any }) => { 35 console.log(response.data) 36 }); 37 }; 38 39 40 return { getListWithMyHttp, getListWithAxios2 } 41 } 42}
No vulnerabilities found.
Reason
no binaries found in the repo
Reason
no dangerous workflow patterns detected
Reason
license file detected
Details
Reason
SAST tool detected but not run on all commits
Details
Reason
security policy file detected
Details
Reason
dependency not pinned by hash detected -- score normalized to 2
Details
Reason
Found 0/7 approved changesets -- score normalized to 0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
detected GitHub workflow tokens with excessive permissions
Details
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
project is not fuzzed
Details
Reason
52 existing vulnerabilities detected
Details
Score
Last Scanned on 2025-03-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn Morevue-cli-plugin-axios
Vue-cli-3 plugin: axios
vue-request
This is a library that can easily help you manage request states, supporting common features such as SWR, polling, error retry, caching, and pagination, etc.
vue-cli-plugin-axios-ts
Vue-cli-3 plugin: axios for ts
@alova/adapter-axios
axios adapter for alova.js