add multi api supports

This commit is contained in:
liangping 2022-01-11 21:08:25 +08:00
parent 044064dcc6
commit feea9009cb

View File

@ -159,8 +159,10 @@ export default {
fetch() {
Object.keys(this.chains).forEach(k => {
const chain = this.chains[k]
const index = localStorage.getItem(`${chain.chain_name}-api-index`) || 0
if (chain.api) {
fetch(`${chain.api}/blocks/latest`).then(res => res.json()).then(b => {
const host = Array.isArray(chain.api) ? chain.api[index] : chain.api
fetch(`${host}/blocks/latest`).then(res => res.json()).then(b => {
// console.log(b.block.header)
const { header } = b.block
this.$set(chain, 'height', header.height)