Skip to content

Commit 1cee994

Browse files
committed
optional timout parameter in ms for axios get requests
1 parent 783cc78 commit 1cee994

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/get-request.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,10 @@ const TESTNET_API_URL_MAP = {
2121
homestead: 'https://api.etherscan.io'
2222
};
2323

24-
module.exports = function(chain) {
24+
module.exports = function(chain, timeout) {
2525
var client = axios.create({
2626
baseURL: pickChainUrl(chain),
27-
timeout: 3000
27+
timeout: timeout
2828
});
2929

3030
/**

lib/init.js

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,18 @@ const account = require('./account');
1414
* @param {string} apiKey - (optional) Your Etherscan APIkey
1515
* @param {string} chain - (optional) Testnet chain keys [ropsten, rinkeby, kovan]
1616
*/
17-
module.exports = function(apiKey, chain) {
17+
module.exports = function(apiKey, chain, timeout) {
1818

1919
if (!apiKey) {
2020
apiKey = 'YourApiKeyToken';
2121
}
2222

23-
var getRequest = require('./get-request')(chain);
23+
24+
if (!timeout) {
25+
apiKey = 3000;
26+
}
27+
28+
var getRequest = require('./get-request')(chain, timeout);
2429

2530
/** @lends module:etherscan/api */
2631
return {

0 commit comments

Comments
 (0)