1.0.4 • Published 6 years ago

vue-http-manager v1.0.4

Weekly downloads
14
License
MIT
Repository
-
Last release
6 years ago

vue-http-manager

vue axios http wrapper

npm

Installation

You can install it via yarn or NPM.

$ npm install vue-http-manager --save

$ yarn add vue-http-manager

Usage

import VueHttp from 'vue-http-manager';
Vue.use(VueHttp);

Example

You can use all of http methods

  • get
  • delete
  • head
  • options
  • post
  • put
  • patch
this.$http.get('/oauth/getInfo', {[data: optional]}) // data = {userId: 95, ...} 
    .then(function (response) {
        console.log(response);  
    })
    .catch(function (error) {
        console.log(error);
    });

OR use recource object

let resource ={
  auth: {
    register: {
      uri: "/oauth/register",
      method: "post"
    },
    getInfo: {
      uri: "/oauth/getInfo/{userId}",
      method: "get"
    }
  }
};

// resource can be a json file
// VueHttp.setResources(require('./recources.json'));

VueHttp.setResources(resource);

let requestData = {
    name: 'amin nazari',
    age: 22,
    ...
};

this.$http.request('auth.register', {data: requestData, params: {userId: 95}}) // params is optional
    .then(function (response) {
        console.log(response);  
    })
    .catch(function (error) {
        console.log(error);
    });
1.0.4

6 years ago

1.0.3

6 years ago

1.0.2

6 years ago

1.0.1

6 years ago

1.0.0

6 years ago

0.17.7

6 years ago

0.17.6

6 years ago

0.17.5

6 years ago

0.17.4

6 years ago

0.17.3

6 years ago

0.17.2

6 years ago

0.17.1

6 years ago