Skip to content

Commit

Permalink
ApiClient: don't override global axios timeout
Browse files Browse the repository at this point in the history
Currently the ApiClient overrides the global axios timeout to 300s which is not expected, instead - create an axios instance and use it.
  • Loading branch information
yosiat committed Mar 3, 2024
1 parent e54d284 commit 109dc0e
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
{{>licenseInfo}}
var axios = require('axios');

axios.defaults.timeout = 300000; // 300s

var axiosInstance = axios.create();

axiosInstance.defaults.timeout = 300000; // 300s

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

return axios
return axiosInstance
.post(url, body)
.then(function (response) {
return response.data;
Expand All @@ -66,7 +69,7 @@ exports.prototype.setDefaultOutputFormat = function (outputFormat) {
};

exports.prototype.setDefaultTimeoutMs = function (timeoutMs) {
axios.defaults.timeout = timeoutMs;
axiosInstance.defaults.timeout = timeoutMs;
}

// The default API client implementation.
Expand Down

0 comments on commit 109dc0e

Please sign in to comment.