diff --git a/src/libs/osmos.js b/src/libs/osmos.js index 6539d6e0..b8daf0ac 100644 --- a/src/libs/osmos.js +++ b/src/libs/osmos.js @@ -91,10 +91,18 @@ export default class OsmosAPI { async get(url) { const chains = getLocalChains() - this.host = chains.osmosis.api + const conf = chains.osmosis + const index = this.getApiIndex(conf) + this.host = Array.isArray(conf.api) ? conf.api[index] : conf.api return fetch(`${this.host}${url}`).then(res => res.json()) } + getApiIndex(config = null) { + const conf = config || this.config + const index = Number(localStorage.getItem(`${conf.chain_name}-api-index`) || 0) + return index < conf.api.length ? index : 0 + } + async getMarketData(from, to, days = 14) { if (from && to) { this.exe_time = ''