vue axios http wrapper
You can install it via yarn or NPM.
$ npm install vue-http-manager --save
$ yarn add vue-http-manager
import VueHttp from 'vue-http-manager';
Vue.use(VueHttp);
- 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);
});
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);
});