Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Progress bar for all api calls at one place in Vue Resource interceptors #75

Open
srabanicn opened this issue Jul 20, 2018 · 2 comments

Comments

@srabanicn
Copy link

srabanicn commented Jul 20, 2018

How can I configure the progress bar for all api calls within Vue Resource Interceptors so that if any API is called it will automatically shows the progress bar on request made and finish/fail according to the response.

I'm using the below code for progress bar and interceptors.

import VueProgressBar from 'vue-progressbar'
const options = {
...
}
Vue.use(VueProgressBar, options)

Vue.http.interceptors.push((request, next) => {
next((response) => {
/** some response content**/
})
})

NOTE: I am not interested to use axios. Solution should be on Vue Resource.

@chiaweilee
Copy link
Contributor

yes, use interceptors.

  • request: this.$Progress.start()
  • response: this.$Progress.finish()
  • fail: this.$Progress.fail()

this should be vm, maybe you can find vm in interceptors, try this:

window.vm = new Vue({...})

@piyushSinghalDemo
Copy link

piyushSinghalDemo commented Sep 3, 2019

@chiaweilee same I am also trying but not getting working in vue-resource intercepter can you please give one simple example.
I am trying
let vm = new Vue({}); Vue.http.interceptors.push((request, next) => { vm.$Progress.start(); // for every request start the progress })
It is same in main.js. still it is showing error that can not read start of undefined.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants