BigW Consortium Gitlab

vue_resource_interceptor.js.es6 348 Bytes
Newer Older
Filipa Lacerda committed
1
/* global Vue */
Filipa Lacerda committed
2 3 4
Vue.http.interceptors.push((request, next) => {
  Vue.activeResources = Vue.activeResources ? Vue.activeResources + 1 : 1;

Filipa Lacerda committed
5 6 7
  next((response) => {
    if (typeof response.data === 'string') {
      response.data = JSON.parse(response.data); // eslint-disable-line
Filipa Lacerda committed
8
    }
Filipa Lacerda committed
9

Filipa Lacerda committed
10
    Vue.activeResources--; // eslint-disable-line
Filipa Lacerda committed
11 12
  });
});