vue-superagent
v1.2.0
Published
A small wrapper for integrating superagent to Vuejs
Downloads
31
Readme
vue-superagent
reference vue-axios
A small wrapper for integrating superagent to Vuejs
How to install:
es6 module:
npm install --save vue-superagent
// or
yarn add vue-superagent
And in your entry file:
import Vue from 'vue'
import VueSuperagent from 'vue-superagent'
Vue.use(VueSuperagent)
// use baseUrl
Vue.use(VueSuperagent, {
baseUrl: 'https://api.douban.com/v2'
})
// *.vue
this.$http
.get('/book/1220562') // => https://api.douban.com/v2/book/1220562
.then(res => console.log(res))
.catch(err => console.log(err));
Usage:
This wrapper bind superagent
to Vue
or this
if you're using single file component.
You can superagent
like this:
Vue.superagent.get(api).then((response) => {
console.log(response.body)
})
this.$superagent.get(api).then((response) => {
console.log(response.body)
})
this.$http.get(api).then((response) => {
console.log(response.body)
})