question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Progress bar for all api calls at one palce

See original GitHub issue

How can we configure the progress bar for all api calls at global place. So that if any api call goes from our app, it will automatically shows the progress bar.

I’m using the below code for interceptors. But when i add it, it’s giving an error. The below code is in main.js where i’m setting the progress bar.

const options = {
  color: '#2ecc71',
  failedColor: '#f16559',
  thickness: '4px',
  transition: {
    speed: '0.2s',
    opacity: '0.5s',
    termination: 300,
  },
  autoRevert: true,
  location: 'top',
  inverse: false,
};
Vue.use(VueProgressBar, options);

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

How can we setup this so that it shows for all api calls, which will reduce the calling of below methods at all api calls.

this.$Progress.start();
this.$Progress.finish();

Issue Analytics

  • State:open
  • Created 6 years ago
  • Reactions:5
  • Comments:11 (1 by maintainers)

github_iconTop GitHub Comments

5reactions
busyhecommented, Dec 20, 2017
import axios from 'axios'
import qs from 'qs'
import Vue from 'vue';
import VueProgressBar from 'vue-progressbar';

Vue.use(VueProgressBar, {});

// eslint-disable-next-line no-new
let newVue = new Vue({});

// 添加请求拦截器
axios.interceptors.request.use(function (config) {
    newVue.$Progress.start();
    return config
}, function (error) {
    return Promise.reject(error)
});
5reactions
ankurk91commented, Dec 20, 2017

I don’t want to troll, but let me know if you could not read my comments inside code above.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple progress bar in multiple view while api call
Anyone have any better solution rather than taking two references of progress bar and toggling its visibility? The implementation should be ...
Read more >
Global Progress Bar on API (s)call in React | by Suman Kunwar
Let's take a look at a simple approach for displaying a progress indicator while these requests complete. First, let's create a reducer to...
Read more >
Connect to an API & Track API request progress ... - YouTube
In this tutorial I showed how to Connect to an API and Track the API request progress with 3 different progress bar styles....
Read more >
Progress bar - IBM
API calls ; stop(string), Stops the progress bar running and changes the message text to the value of string. If you do not...
Read more >
How to monitor the progress of a Javascript fetch - request and ...
The progress indicator will visualize the fetch - progress ... I'm using this repository's hosted API as a starting place.
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found