From f75a10aa3b831c8a176774d2290e7bfffec19c02 Mon Sep 17 00:00:00 2001 From: Yosi Attias Date: Sun, 3 Mar 2024 15:47:11 +0200 Subject: [PATCH] ApiClient: don't override global axios timeout Currently the ApiClient overrides the global axios timeout to 300s which is not expected, instead - create an axios instance and use it. --- .../javascript/templates/ApiClient.mustache | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/swagger-config/transactional/javascript/templates/ApiClient.mustache b/swagger-config/transactional/javascript/templates/ApiClient.mustache index ac8301a..b27b385 100644 --- a/swagger-config/transactional/javascript/templates/ApiClient.mustache +++ b/swagger-config/transactional/javascript/templates/ApiClient.mustache @@ -1,7 +1,10 @@ {{>licenseInfo}} var axios = require('axios'); -axios.defaults.timeout = 300000; // 300s +var axiosInstance = axios.create({ + timeout: 300000 // 300s +}); + {{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}{{#-first}}var {{baseName}} = require('./api/{{classname}}'); {{/-first}}{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}} @@ -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; @@ -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.