fix refreshBTCPrice being out of scope
This commit is contained in:
parent
9c73e1bc15
commit
a942a8efd1
|
|
@ -53,6 +53,21 @@ class Blockonomics {
|
|||
refreshIcon.classList.add('rotating');
|
||||
document.getElementsByClassName("btc-value")[0].innerHTML = "Refreshing...";
|
||||
|
||||
const getBTCPrice = async () => {
|
||||
try {
|
||||
const currency = document.querySelector('meta[name="currency"]').content;
|
||||
const response = await fetch(`/api/v1/get-btc-price?currency=${currency}`); // New endpoint to call server-side function
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
const data = await response.json();
|
||||
return data.price;
|
||||
} catch (error) {
|
||||
console.error('There was a problem with the BTC price fetch operation:', error);
|
||||
// Handle error appropriately
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
const newPrice = await getBTCPrice();
|
||||
if (newPrice) {
|
||||
|
|
@ -117,21 +132,6 @@ class Blockonomics {
|
|||
window.countdownInterval = setInterval(updateCountdown, 1000);
|
||||
}
|
||||
|
||||
const getBTCPrice = async () => {
|
||||
try {
|
||||
const currency = document.querySelector('meta[name="currency"]').content;
|
||||
const response = await fetch(`/api/v1/get-btc-price?currency=${currency}`); // New endpoint to call server-side function
|
||||
if (!response.ok) {
|
||||
throw new Error('Network response was not ok');
|
||||
}
|
||||
const data = await response.json();
|
||||
return data.price;
|
||||
} catch (error) {
|
||||
console.error('There was a problem with the BTC price fetch operation:', error);
|
||||
// Handle error appropriately
|
||||
}
|
||||
}
|
||||
|
||||
const connectToWebsocket = () => {
|
||||
const btcAddress = document.querySelector('meta[name="btc_address"]').content;
|
||||
const webSocketUrl = `wss://www.blockonomics.co/payment/${btcAddress}`;
|
||||
|
|
|
|||
Loading…
Reference in New Issue