Skip to content

Commit 033f0da

Browse files
author
Pooya Parsa
committed
test: add retry to tests
#77
1 parent 7221cac commit 033f0da

File tree

2 files changed

+8
-5
lines changed

2 files changed

+8
-5
lines changed

lib/plugin.template.js

+3-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import Axios from 'axios'
2+
<% if (options.retry) { %>import axiosRetry from 'axios-retry'<% } %>
23

34
// Axios.prototype cannot be modified
45
const axiosExtra = {
@@ -169,7 +170,8 @@ export default (ctx, inject) => {
169170
// Setup interceptors
170171
<% if (options.debug) { %>setupDebugInterceptor(axios) <% } %>
171172
<% if (options.credentials) { %>setupCredentialsInterceptor(axios)<% } %>
172-
<% if (options.progress) { %>setupProgress(axios, ctx)<% } %>
173+
<% if (options.progress) { %>setupProgress(axios, ctx) <% } %>
174+
<% if (options.retry) { %>axiosRetry(axios, <%= typeof options.retry === 'object' ? JSON.stringify(options.retry, undefined, 2) : '{}' %>)<% } %>
173175

174176
// Inject axios to the context as $axios
175177
ctx.$axios = axios

test/fixture/nuxt.config.js

+5-4
Original file line numberDiff line numberDiff line change
@@ -13,9 +13,10 @@ module.exports = {
1313
prefix: `/test_api`,
1414
proxy: true,
1515
credentials: true,
16-
debug: true
16+
debug: true,
17+
retry: {
18+
retries: 3
19+
}
1720
},
18-
plugins: [
19-
'~/plugins/axios'
20-
]
21+
plugins: ['~/plugins/axios']
2122
}

0 commit comments

Comments
 (0)