Skip to content

aminNazarii/vue-http-manager

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

vue axios http wrapper

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published