Vue-resource: Vue-spinner usage in vue-resource interceptor

Created on 18 Sep 2016  路  2Comments  路  Source: pagekit/vue-resource

Hi,
I'm using vue-resource and I'd like to use vue-spinner (https://github.com/greyby/vue-spinner) inside interceptors to show/hide the spinner on any ajax request. I don't know if it's possible to reference a vue-spinner component inside the interceptor. I have done the following but with no success: (I'm using vueify)

var PulseLoader = require('vue-spinner/dist/vue-spinner.min').PulseLoader;

Vue.http.interceptors.push((request, next) => {
    this.loading = true;
   next((response) => {
        this.loading = false;
    });
});

new Vue({
    el: '#grid-manager',
   components: { 'pulse-loader': PulseLoader},

  ....and in the root vue instance i have:

<pulse-loader :loading="loading" :color="color" :size="size"></pulse-loader>

Thanks!

Most helpful comment

Hi,
you can use this: nprogress instead of vue-spinner

import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

Vue.http.interceptors.push((request, next) => {
    NProgress.start();
    next((response)=>{
        NProgress.done();
      });
});

All 2 comments

Hi,
you can use this: nprogress instead of vue-spinner

import NProgress from 'nprogress'
import 'nprogress/nprogress.css'

Vue.http.interceptors.push((request, next) => {
    NProgress.start();
    next((response)=>{
        NProgress.done();
      });
});

Thanks @gg87 . I think this is a better solution than using vue-spinner.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

christophwolff picture christophwolff  路  6Comments

gbhlwm picture gbhlwm  路  5Comments

facesea picture facesea  路  5Comments

odranoelBR picture odranoelBR  路  6Comments

mikeyao picture mikeyao  路  6Comments