Skip to content

Commit

Permalink
small update to timeout config and axios version
Browse files Browse the repository at this point in the history
  • Loading branch information
Iulian Masar committed Nov 23, 2023
1 parent ecbcaa6 commit 075411a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
9 changes: 6 additions & 3 deletions lib/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,10 @@ var Api = function (config) {
config = this.config = _.extend({}, defaultConfig, config);

axios.defaults.baseURL = config.baseUrl;
axios.defaults.timeout = config.connectionTimeout + config.responseTimeout;
// response timeout
axios.defaults.timeout = config.responseTimeout;
// request timeout
axios.defaults.signal = AbortSignal.timeout(config.connectionTimeout);

this.errorHandler = config.errorHandler;

Expand Down Expand Up @@ -408,12 +411,12 @@ function setRateLimits(self, headers) {
}
}

function replaceUrl(text, data) {
function replaceUrl(url, data) {
// Create regex using the keys of the replacement object.
const regex = new RegExp('\\${(' + Object.keys(data).join('|') + ')}', 'g');

// Replace the string by the value in object
return text.replace(regex, (m, p1) => data[p1] || m);
return url.replace(regex, (m, p1) => data[p1] || m);
}

module.exports = Api;
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"main": "./index.js",
"dependencies": {
"@types/node": "14.14.x",
"axios": "^1.5.1",
"axios": "1.6.2",
"promise": "8.1.x",
"underscore": "1.12.x"
},
Expand Down

0 comments on commit 075411a

Please sign in to comment.