UNPKG

1.1 kBMarkdownView Raw
1# vue-axios
2A small wrapper for integrating axios to Vuejs
3
4## Support matrix
5
6|VueJS \ VueAxios|1.x|2.x|3.x|
7|-|-|-|-|
8|1.x|✔|✔|✔|
9|2.x|✔|✔|✔|
10|3.x|❌|❌|✔|
11
12## How to install:
13### ES6 Module:
14```bash
15npm install --save axios vue-axios
16```
17Import libraries in entry file:
18```js
19import Vue from 'vue'
20import axios from 'axios'
21import VueAxios from 'vue-axios'
22```
23
24Usage in Vue 2:
25```js
26Vue.use(VueAxios, axios)
27```
28
29Usage in Vue 3:
30```js
31const app = Vue.createApp(...)
32app.use(VueAxios, axios)
33```
34
35### Script:
36Just add 3 scripts in order: `vue`, `axios` and `vue-axios` to your `document`.
37
38## Usage:
39This wrapper bind `axios` to `Vue` or `this` if you're using single file component.
40
41You can use `axios` like this:
42```js
43Vue.axios.get(api).then((response) => {
44 console.log(response.data)
45})
46
47this.axios.get(api).then((response) => {
48 console.log(response.data)
49})
50
51this.$http.get(api).then((response) => {
52 console.log(response.data)
53})
54```
55
56Please kindly check full documention of [axios](https://github.com/axios/axios) too