const API_KEY = 'YOUR_API_KEY'; // <- Replace this with your real API Key const API_URL = `https://api.metals.dev/v1/latest?api_key=${API_KEY}&base=USD&symbols=XAU`; async function updateGoldTicker() { try { const response = await fetch(API_URL); const data = await response.json(); const goldPriceUSD = data?.rates?.XAU; if (goldPriceUSD) { const goldPriceGBP = (goldPriceUSD * 0.80); // Rough USD to GBP const tickerText = `Live Gold Price: £${goldPriceGBP.toFixed(2)} GBP | Updated every minute | exgold.co.uk ✨`; document.getElementById('gold-ticker-text').innerText = tickerText; } else { document.getElementById('gold-ticker-text').innerText = 'Gold price unavailable at the moment.'; } } catch (error) { console.error('Error fetching gold price:', error); document.getElementById('gold-ticker-text').innerText = 'Error fetching gold price.'; } } // Initial fetch updateGoldTicker(); // Refresh every 60 seconds setInterval(updateGoldTicker, 60000); const API_KEY = 'YOUR_API_KEY'; // <- Replace this with your real API Key const API_URL = `https://api.metals.dev/v1/latest?api_key=${API_KEY}&base=USD&symbols=XAU`; async function updateGoldTicker() { try { const response = await fetch(API_URL); const data = await response.json(); const goldPriceUSD = data?.rates?.XAU; if (goldPriceUSD) { const goldPriceGBP = (goldPriceUSD * 0.80); // Rough USD to GBP const tickerText = `Live Gold Price: £${goldPriceGBP.toFixed(2)} GBP | Updated every minute | exgold.co.uk ✨`; document.getElementById('gold-ticker-text').innerText = tickerText; } else { document.getElementById('gold-ticker-text').innerText = 'Gold price unavailable at the moment.'; } } catch (error) { console.error('Error fetching gold price:', error); document.getElementById('gold-ticker-text').innerText = 'Error fetching gold price.'; } } // Initial fetch updateGoldTicker(); // Refresh every 60 seconds setInterval(updateGoldTicker, 60000);
position:fixed; bottom:0;