vue-superagent

1.2.0 • Public • Published

vue-superagent

reference vue-axios

A small wrapper for integrating superagent to Vuejs

NPM

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)
})

Readme

Keywords

Package Sidebar

Install

npm i vue-superagent

Weekly Downloads

12

Version

1.2.0

License

MIT

Last publish

Collaborators

  • f-loat