From 7f58aa12d6cd9457920ea7bf745dbd6d6350019d Mon Sep 17 00:00:00 2001 From: Ritika-Agrawal0811 Date: Tue, 8 Jun 2021 10:38:13 +0530 Subject: [PATCH] bug fix --- index.html | 65 ++++++++++++++++++++++++++++-------------------------- 1 file changed, 34 insertions(+), 31 deletions(-) diff --git a/index.html b/index.html index d3aae06..b3634ba 100644 --- a/index.html +++ b/index.html @@ -7863,37 +7863,40 @@ util: { serverList: floGlobals.apiURL[floGlobals.blockchain].slice(0), curPos: floCrypto.randInt(0, floGlobals.apiURL[floGlobals.blockchain].length - 1), - fetch_retry: function (apicall) { - return new Promise((resolve, reject) => { - this.serverList.splice(this.curPos, 1); - this.curPos = floCrypto.randInt(0, this.serverList.length - 1) - this.fetch_api(apicall) - .then(result => resolve(result)) - .catch(error => reject(error)); - }) - }, - fetch_api: function (apicall) { - return new Promise((resolve, reject) => { - if (this.serverList.length === 0) - reject("No floSight server working") - else { - fetch(this.serverList[this.curPos] + apicall).then(response => { - if (response.ok) - response.json().then(data => resolve(data)); - else { - this.fetch_retry(apicall) - .then(result => resolve(result)) - .catch(error => reject(error)); - } - }).catch(error => { - this.fetch_retry(apicall) - .then(result => resolve(result)) - .catch(error => reject(error)); - }) - } - }) - } - }, + fetch_retry: function (apicall, rm_flosight) { + return new Promise((resolve, reject) => { + let i = this.serverList.indexOf(rm_flosight) + if(i != -1) + this.serverList.splice(i, 1); + this.curPos = floCrypto.randInt(0, this.serverList.length) + this.fetch_api(apicall) + .then(result => resolve(result)) + .catch(error => reject(error)); + }) + }, + fetch_api: function (apicall) { + return new Promise((resolve, reject) => { + if (this.serverList.length === 0) + reject("No floSight server working") + else { + let flosight = this.serverList[this.curPos]; + fetch(flosight + apicall).then(response => { + if (response.ok) + response.json().then(data => resolve(data)); + else { + this.fetch_retry(apicall, flosight) + .then(result => resolve(result)) + .catch(error => reject(error)); + } + }).catch(error => { + this.fetch_retry(apicall, flosight) + .then(result => resolve(result)) + .catch(error => reject(error)); + }) + } + }) + } + }, //Promised function to get data from API promisedAPI: function (apicall) {