UNPKG

728 BMarkdownView Raw
1# vue-axios
2A small wrapper for integrating axios to Vuejs
3
4## How to install:
5### CommonJS:
6```bash
7npm install --save axios vue-axios
8```
9
10And in your entry file:
11```js
12import Vue from 'vue'
13import axios from 'axios'
14import VueAxios from 'vue-axios'
15
16Vue.use(VueAxios, axios)
17```
18
19### Script:
20Just add 3 scripts in order: `vue`, `axios` and `vue-axios` to your `document`.
21
22## Usage:
23This wrapper bind `axios` to `Vue` or `this` if you're using single file component.
24
25You can `axios` like this:
26```js
27Vue.axios.get(api).then((response) => {
28 console.log(response.data)
29})
30
31this.axios.get(api).then((response) => {
32 console.log(response.data)
33})
34
35this.$http.get(api).then((response) => {
36 console.log(response.data)
37})
38```