vue-bulma / nprogress

Progress bars is based on nprogress for Vue
MIT License
184 stars 31 forks source link

axios support #9

Closed gyamxxx closed 7 years ago

gyamxxx commented 7 years ago

Retiring vue-resource https://medium.com/the-vue-point/retiring-vue-resource-871a82880af4#.9oiug628f

so, could u support axios on option.http ?

const options = {
  latencyThreshold: 200, // Number of ms before progressbar starts showing, default: 100,
  router: true, // Show progressbar when navigating routes, default: true
  http: false // Show progressbar when doing Vue.http, default: true
};
bigggge commented 7 years ago

+1

bigggge commented 7 years ago

You can use interceptors

// Add a request interceptor
axios.interceptors.request.use(function (config) {
  // Do something before request is sent
  NProgress.start();
  return config;
}, function (error) {
  // Do something with request error
  console.error(error)
  return Promise.reject(error);
});

// Add a response interceptor
axios.interceptors.response.use(function (response) {
  // Do something with response data
  NProgress.done();
  return response;
}, function (error) {
  // Do something with response error
  console.error(error)
  return Promise.reject(error);
});
luventa commented 7 years ago

Hi @gyamxxx , sorry for replying so late....too busy with personal affairs these days. What @bigggge said is exactly correct. And I will update the vue-admin with Axios recently as a demo for this issue.

Thanks guys!