diff --git a/src/OrsBase.js b/src/OrsBase.js index 36ee2a7..e7c25d1 100644 --- a/src/OrsBase.js +++ b/src/OrsBase.js @@ -25,6 +25,9 @@ class OrsBase { if (args[Constants.propNames.service]) { this.defaultArgs[Constants.propNames.service] = args[Constants.propNames.service] } + if (args[Constants.propNames.timeout]) { + this.defaultArgs[Constants.propNames.timeout] = args[Constants.propNames.timeout] + } if (Constants.propNames.apiKey in args) { this.defaultArgs[Constants.propNames.apiKey] = args[Constants.propNames.apiKey] } else if (!args[Constants.propNames.host]) { @@ -32,7 +35,6 @@ class OrsBase { console.error(Constants.missingAPIKeyMsg) throw new Error(Constants.missingAPIKeyMsg) } - } checkHeaders() { @@ -65,7 +67,7 @@ class OrsBase { async createRequest(body) { const controller = new AbortController() - const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000) + const timeout = setTimeout(() => controller.abort(), this.defaultArgs[Constants.propNames.timeout] || 5000) try { const orsResponse = await this.fetchRequest(body, controller) diff --git a/src/OrsGeocode.js b/src/OrsGeocode.js index afa7e86..fa82b0a 100644 --- a/src/OrsGeocode.js +++ b/src/OrsGeocode.js @@ -129,7 +129,7 @@ class OrsGeocode extends OrsBase { async geocodePromise() { const controller = new AbortController() - const timeout = setTimeout(() => controller.abort('timed out'), this.defaultArgs[Constants.propNames.timeout] || 5000) + const timeout = setTimeout(() => controller.abort(), this.defaultArgs[Constants.propNames.timeout] || 5000) try { const orsResponse = await this.fetchGetRequest(controller)