wowtoken.app

git clone https://git.emily.sh/wowtoken-app/wowtoken.app.git
Log | Files | Refs | README | LICENSE

commit 0180e8a3b59a79f1da202abd59bbe403e84726e9
parent fa058cc64e061742a04cb7fa8283d78bcd7c0755
Author: Emily Doherty <git@emily.sh>
Date:   Fri,  1 Nov 2024 00:09:19 -0700

Swap to v2 of the historical api

Diffstat:
Msrc/fetchData.js | 2+-
Msrc/index.html | 4++--
Msrc/urlBuilder.js | 12++++++++----
3 files changed, 11 insertions(+), 7 deletions(-)

diff --git a/src/fetchData.js b/src/fetchData.js @@ -6,7 +6,7 @@ export default async function fetchData(currentRegionSelection, currentTimeSelec const resp = await fetch(urlBuilder(currentRegionSelection, currentTimeSelection, currentAggregateSelection)); const respData = await resp.json(); for (let i = 0, l = respData.length; i < l; i++) { - let datum = new Datum(Date.parse(respData[i]['time']), respData[i]['value']); + let datum = new Datum(Date.parse(respData[i][0]), respData[i][1]); data.push(datum); } return data; diff --git a/src/index.html b/src/index.html @@ -8,7 +8,7 @@ <link rel="preconnect" href="https://data.wowtoken.app"> <link rel="dns-prefetch" href="https://data.wowtoken.app"> <link rel="preload" href="https://data.wowtoken.app/v2/current/retail.json" as="fetch" type="application/json" crossorigin="anonymous"> - <link rel="preload" href="https://data.wowtoken.app/token/history/us/72h.json" as="fetch" type="application/json" crossorigin="anonymous"> + <link rel="preload" href="https://data.wowtoken.app/v2/relative/retail/us/72h.json" as="fetch" type="application/json" crossorigin="anonymous"> </head> <body> <div class="flex-container"> @@ -59,7 +59,7 @@ <label for="aggregate">Smoothing Function:</label> <select name="aggregate" id="aggregate"> <option id='agg_none' value="none">None</option> - <option id='agg_davg' value="daily_mean">Daily Average</option> + <option id='agg_davg' value="avg">Daily Average</option> </select> </fieldset> <fieldset id="y-start-options"> diff --git a/src/urlBuilder.js b/src/urlBuilder.js @@ -1,8 +1,12 @@ export default function urlBuilder(currentRegionSelection, currentTimeSelection, currentAggregateSelection) { - let url = "https://data.wowtoken.app/token/history/"; - if (currentAggregateSelection !== 'none') { - url += `${currentAggregateSelection}/` + let url = "https://data.wowtoken.app/v2/"; + if (currentAggregateSelection !== '' && currentAggregateSelection !== 'none'){ + url += `math/${currentAggregateSelection}/retail/` } - url += `${currentRegionSelection}/${currentTimeSelection}.json` + else { + url += `relative/retail/` + } + + url += `${currentRegionSelection}/${currentTimeSelection}.json`; return url; } \ No newline at end of file