fix broken banner

This commit is contained in:
Karol Wypchlo 2020-03-09 18:50:16 +01:00
parent 2cd683c8e8
commit bb13689b1a
3 changed files with 10 additions and 9 deletions

View File

@ -4,6 +4,7 @@
"version": "1.0.0",
"author": "Nebulous",
"dependencies": {
"axios": "^0.19.2",
"classnames": "^2.2.6",
"gatsby": "^2.19.32",
"gatsby-image": "^2.2.43",

View File

@ -1,4 +1,5 @@
import { useEffect, useState } from "react";
import axios from "axios";
export const AVAILABLE_STATS = {
ONLINE_HOSTS_COUNT: "onlineHostsCount",
@ -32,9 +33,9 @@ export default function useStats() {
async function getBandwidthStats() {
// { up: 76.09, down: 102.66, upusd: 0.23, downusd: 0.32 }
const response = await fetch("https://siastats.info/dbs/bandwidthpricesdb.json");
const data = await response.json();
const current = data[data.length - 1];
const { data } = await axios.get("https://siastats.info/dbs/bandwidthpricesdb.json");
// some entries do not contain the required property so make sure to get one that does
const current = data.reverse().find((entry) => "downusd" in entry);
return {
[AVAILABLE_STATS.BANDWIDTH_DOWN_COST_USD]: current.downusd
@ -43,9 +44,9 @@ async function getBandwidthStats() {
async function getPriceStats() {
// { price: 504.59, newcontractformation: 30.79, usd: 1.55, sfperfees: 8.98 }
const response = await fetch("https://siastats.info/dbs/storagepricesdb.json");
const data = await response.json();
const current = data[data.length - 1];
const { data } = await axios.get("https://siastats.info/dbs/storagepricesdb.json");
// some entries do not contain the required property so make sure to get one that does
const current = data.reverse().find((entry) => "usd" in entry);
return {
[AVAILABLE_STATS.STORAGE_COST_USD]: current.usd
@ -57,8 +58,7 @@ async function getStorageStats() {
// difficulty: 3501953420754597000, coin_supply: 43638591164, coin_price_USD: 0.003,
// market_cap_USD: 130915773, used_storage_TB: 725.26, network_capacity_TB: 2270.96,
// online_hosts: 360, active_contracts: 62997 }
const response = await fetch("https://siastats.info/dbs/network_status.json");
const data = await response.json();
const { data } = await axios.get("https://siastats.info/dbs/network_status.json");
return {
[AVAILABLE_STATS.ONLINE_HOSTS_COUNT]: data.online_hosts,

View File

@ -1994,7 +1994,7 @@ aws4@^1.8.0:
resolved "https://registry.yarnpkg.com/aws4/-/aws4-1.9.1.tgz#7e33d8f7d449b3f673cd72deb9abdc552dbe528e"
integrity sha512-wMHVg2EOHaMRxbzgFJ9gtjOOCrI80OHLG14rxi28XwOW8ux6IiEbRCGGGqCtdAIg4FQCbW20k9RsT4y3gJlFug==
axios@^0.19.0:
axios@^0.19.0, axios@^0.19.2:
version "0.19.2"
resolved "https://registry.yarnpkg.com/axios/-/axios-0.19.2.tgz#3ea36c5d8818d0d5f8a8a97a6d36b86cdc00cb27"
integrity sha512-fjgm5MvRHLhx+osE2xoekY70AhARk3a6hkN+3Io1jc00jtquGvxYlKlsFUhmUET0V5te6CcZI7lcv2Ym61mjHA==