turn off bitstamp (blocked by cors)

This commit is contained in:
2023-12-07 05:07:15 +01:00
parent edd84c9000
commit 0d596a9506

View File

@@ -34,12 +34,12 @@ const dataSources = [
pick: res => +res.result.XXBTZUSD.a[0], pick: res => +res.result.XXBTZUSD.a[0],
asset: 'USD', asset: 'USD',
}, },
{ // {
name: 'bitstamp', // name: 'bitstamp',
url: 'https://www.bitstamp.net/api/v2/ticker/btcusd', // url: 'https://www.bitstamp.net/api/v2/ticker/btcusd',
pick: res => +res.last, // pick: res => +res.last,
asset: 'USD', // asset: 'USD',
}, // },
{ {
name: 'coingecko', name: 'coingecko',
url: 'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd', url: 'https://api.coingecko.com/api/v3/simple/price?ids=bitcoin&vs_currencies=usd',
@@ -67,13 +67,14 @@ const prices = ref([]);
(() => { (() => {
let idx = -1; let idx = -1;
const loop = () => { const loop = async () => {
idx = (idx + 1) % dataSources.length;
const source = dataSources[idx];
get(source.url).then(res => {
prices.value[idx] = source.pick(res);
}).then(calcAverage);
setTimeout(loop, TIMEOUT / dataSources.length); setTimeout(loop, TIMEOUT / dataSources.length);
idx = (idx + 1) % dataSources.length;
try {
const source = dataSources[idx];
prices.value[idx] = source.pick(await get(source.url));
calcAverage();
} catch (e) {};
}; };
loop(); loop();
})(); })();