@aventure-cloud/vuejs-axios-bridge

0.0.9 • Public • Published

Vuejs Axios Bridge

Axios plugin with progress bar and autenthication configuration

Dependencies

Plugin ship with NProgress as progress bar module integrated by default.

Install

npm i -S @aventure-cloud/vuejs-axios-bridge

Integrate in your project

You can inject a configuration object with two main properties:

  • axios for axios configuration
  • progress for NProgress configuration

To discover all passible configuration of this two module read their official documentation.

import AxiosPlugin from '@aventure-cloud/vuejs-axios-bridge';
Vue.use(AxiosPlugin, {
    axios: {
        baseURL: 'api',
        headers: {
            'Authorization': 'Bearer ' + User.api_token
        }
    },
    progress: {
        showSpinner: true
    }
});

Add nprogress style

Import nprogress style in your sass:

@import "../node_modules/@aventure-cloud/vuejs-axios-bridge/assets/nprogress";

Use

export default {
    data(){
        return {
            items: []
        };
    },
    
    mounted(){
        this.$axios.get('items')
            .then(response => {
                this.items = response.data;
            });
    }
    
}

Disable progress bar

If you don't want use a progress bar you can disable it:

import AxiosPlugin from '@aventure-cloud/vuejs-axios-bridge';
Vue.use(AxiosPlugin, {
    axios: {
        ...
    },
    progress: false
})

Readme

Keywords

none

Package Sidebar

Install

npm i @aventure-cloud/vuejs-axios-bridge

Weekly Downloads

9

Version

0.0.9

License

MIT

Unpacked Size

10.5 kB

Total Files

9

Last publish

Collaborators

  • valerione