2.3.1 • Published 3 years ago
sb-axios-wrapper v2.3.1
AxiosWrapper Usage
Basic usage
PUT or POST
this.request("post", this.route, this.form);
With callback function
this.request("post", this.route, this.form, {
onSuccess: () => {
this.showModal = false
}
});
GET
this.request("get", this.route, {}, {
onSuccess: (response) => {
this.items = response.data.items
}
});
With options
this.request("post", this.route, this.form, {
// (defaul is true)
shouldNotifyError: false,
// (defaul is true)
shouldNotifySuccess: false,
// these options will be passed to the notify function to be provided by you as a global function.
errorOptions: {
timeout: 2000,
},
successOptions: {
timeout: 2000,
}
});
installation
npm install sb-axios-wrapper
Then, register axios-wrapper in your app entry point (typically app.js or main.js):
import AxiosWrapper from 'sb-axios-wrapper'
Vue.mixin(AxiosWrapper)
Important: this mixin adds 4 attributes to the component mixin
requestProcessing: (boolean)
responseErrors: (Object) // (validation errors)
responseMessage: (string)
responseMessages: (array)
Listen for package event
This package emit a "notify" event with status ("success" or "error") and the message (or messages) from response which can be used to display a notification to the user.
const app = new Vue({
el: '#app',
});
app.$root.$on('notify', (options) => {
console.log(options)
})
2.3.1
3 years ago
2.3.0
3 years ago
2.2.0
3 years ago
2.0.0
3 years ago
1.3.7
3 years ago
1.3.6
3 years ago
1.3.5
3 years ago
1.3.4
3 years ago
1.3.3
3 years ago
1.3.2
3 years ago
1.3.1
3 years ago
1.3.0
3 years ago
1.2.1
3 years ago
1.2.0
3 years ago
1.1.0
3 years ago
1.0.9
3 years ago
1.0.8
3 years ago
1.0.7
3 years ago
1.0.6
3 years ago
1.0.5
3 years ago
1.0.4
3 years ago
1.0.3
3 years ago
1.0.2
3 years ago
1.0.1
3 years ago
1.0.0
3 years ago