Skip to content

Commit 1530bb6

Browse files
author
Pooya Parsa
committed
feat: allow disable progress per request. closes #112.
1 parent ab2717b commit 1530bb6

File tree

2 files changed

+21
-3
lines changed

2 files changed

+21
-3
lines changed

docs/options.md

+6
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ If set to `true`, `http://` in both `baseURL` and `browserBaseURL` will be chang
3838

3939
Integrate with Nuxt.js progress bar to show a loading bar while making requests. (Only on browser, when loading bar is available.)
4040

41+
You can also disable progress bar per request using `progress` config.
42+
43+
```js
44+
this.$axios.$get('URL', { progress: false })
45+
```
46+
4147
### `proxy`
4248

4349
* Default: `false`

lib/plugin.template.js

+15-3
Original file line numberDiff line numberDiff line change
@@ -105,19 +105,31 @@ const setupProgress = (axios, ctx) => {
105105

106106
let currentRequests = 0
107107

108-
axios.onRequest(() => {
108+
axios.onRequest(config => {
109+
if (config && config.progress === false) {
110+
return
111+
}
112+
109113
currentRequests++
110114
})
111115

112-
axios.onResponse(() => {
116+
axios.onResponse(response => {
117+
if (response && response.config && response.config.progress === false) {
118+
return
119+
}
120+
113121
currentRequests--
114122
if (currentRequests <= 0) {
115123
currentRequests = 0
116124
$loading().finish()
117125
}
118126
})
119127

120-
axios.onError(() => {
128+
axios.onError(error => {
129+
if (error && error.config && error.config.progress === false) {
130+
return
131+
}
132+
121133
currentRequests--
122134
$loading().fail()
123135
$loading().finish()

0 commit comments

Comments
 (0)