Skip to content

Commit 8071978

Browse files
authored
Merge pull request #357 from yosiat/isolate-axios
ApiClient: don't override global axios timeout
2 parents dfbc900 + f75a10a commit 8071978

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

swagger-config/transactional/javascript/templates/ApiClient.mustache

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
{{>licenseInfo}}
22
var axios = require('axios');
33

4-
axios.defaults.timeout = 300000; // 300s
4+
var axiosInstance = axios.create({
5+
timeout: 300000 // 300s
6+
});
7+
58

69
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#-first}}var {{baseName}} = require('./api/{{classname}}');
710
{{/-first}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
@@ -47,7 +50,7 @@ exports.prototype.post = function post(path, body = {}) {
4750
url = url + '.' + defaultOutputFormat;
4851
}
4952

50-
return axios
53+
return axiosInstance
5154
.post(url, body)
5255
.then(function (response) {
5356
return response.data;
@@ -66,7 +69,7 @@ exports.prototype.setDefaultOutputFormat = function (outputFormat) {
6669
};
6770

6871
exports.prototype.setDefaultTimeoutMs = function (timeoutMs) {
69-
axios.defaults.timeout = timeoutMs;
72+
axiosInstance.defaults.timeout = timeoutMs;
7073
}
7174

7275
// The default API client implementation.

0 commit comments

Comments
 (0)