Skip to content

F-loat/vue-superagent

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vue-superagent

npm package npm downloads

A small wrapper for integrating superagent to Vuejs (reference vue-axios)

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

About

⚡A small wrapper for integrating superagent to Vuejs

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published