From a0796dacc5be36106705962629356cad6fa21350 Mon Sep 17 00:00:00 2001 From: Sam Date: Wed, 14 Aug 2024 17:59:38 +0100 Subject: [PATCH] Change api endpoints to use apiURL --- static/js/bitcoin-business-growth-chart.js | 3 ++- static/js/bitcoin-business-growth-table.js | 3 +-- static/js/bitcoin-price.js | 2 +- static/js/feerate-percentile.js | 3 +-- static/js/hashrate.js | 3 +-- static/js/miner-rewards.js | 3 +-- 6 files changed, 7 insertions(+), 10 deletions(-) diff --git a/static/js/bitcoin-business-growth-chart.js b/static/js/bitcoin-business-growth-chart.js index bd38333..317cbe4 100644 --- a/static/js/bitcoin-business-growth-chart.js +++ b/static/js/bitcoin-business-growth-chart.js @@ -3,7 +3,8 @@ let myChart; async function fetchDataForChart(str) { try { - const apiEndpoint = `https://api.baseddata.io/bitcoin_business_growth_by_country?cumulative_period_type=365 day&countries=${str}`; + const apiEndpoint = `${apiURL}/bitcoin_business_growth_by_country?cumulative_period_type=365 day&countries=${str}`; + console.log("Fetching from " + apiEndpoint); const response = await fetch(apiEndpoint); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); diff --git a/static/js/bitcoin-business-growth-table.js b/static/js/bitcoin-business-growth-table.js index d7868c1..fc0cb7e 100644 --- a/static/js/bitcoin-business-growth-table.js +++ b/static/js/bitcoin-business-growth-table.js @@ -3,8 +3,7 @@ async function fetchDataForTable() { const dropdown = document.querySelector(".dropdownFilter"); let selectedIndex = dropdown.selectedIndex; let selectedValue = dropdown.options[selectedIndex].value; - const apiEndpoint = - "https://api.baseddata.io/bitcoin_business_growth_by_country?latest_date=true"; + const apiEndpoint = `${apiURL}/bitcoin_business_growth_by_country?latest_date=true`; const response = await fetch( apiEndpoint + `&cumulative_period_type=${selectedValue}`, ); diff --git a/static/js/bitcoin-price.js b/static/js/bitcoin-price.js index 20fa3f3..19ac2df 100644 --- a/static/js/bitcoin-price.js +++ b/static/js/bitcoin-price.js @@ -3,7 +3,7 @@ const myChart = echarts.init(document.getElementById("chart")); async function fetchDataForChart() { try { - const apiEndpoint = "https://api.baseddata.io/get_json/final__price.json"; + const apiEndpoint = `${apiURL}/get_json/final__price.json`; const response = await fetch(apiEndpoint); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); diff --git a/static/js/feerate-percentile.js b/static/js/feerate-percentile.js index ae31269..87fe241 100644 --- a/static/js/feerate-percentile.js +++ b/static/js/feerate-percentile.js @@ -3,8 +3,7 @@ const myChart = echarts.init(document.getElementById("chart")); async function fetchDataForChart() { try { - const apiEndpoint = - "https://api.baseddata.io/get_json/final__feerate_percentiles.json"; + const apiEndpoint = `${apiURL}/get_json/final__feerate_percentiles.json`; const response = await fetch(apiEndpoint); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); diff --git a/static/js/hashrate.js b/static/js/hashrate.js index fbba32c..7dcdcad 100644 --- a/static/js/hashrate.js +++ b/static/js/hashrate.js @@ -3,8 +3,7 @@ const myChart = echarts.init(document.getElementById("chart")); async function fetchDataForChart() { try { - const apiEndpoint = - "https://api.baseddata.io/get_json/final__hashrate.json"; + const apiEndpoint = `${apiURL}/get_json/final__hashrate.json`; const response = await fetch(apiEndpoint); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); diff --git a/static/js/miner-rewards.js b/static/js/miner-rewards.js index 91da986..f138e76 100644 --- a/static/js/miner-rewards.js +++ b/static/js/miner-rewards.js @@ -3,8 +3,7 @@ const myChart = echarts.init(document.getElementById("chart")); async function fetchDataForChart() { try { - const apiEndpoint = - "https://api.baseddata.io/get_json/final__miner_rewards.json"; + const apiEndpoint = `${apiURL}/get_json/${filename}?period=${selectedValue}`; const response = await fetch(apiEndpoint); if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`);