réponses
251 vues
dev_blockchain
245 XP
a répondu
document.addEventListener("DOMContentLoaded", () => { const tableBody = document.querySelector("tbody");
1// Replace with your CoinGecko API endpoint to get the top 500 cryptocurrencies2const apiUrl = "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd...;;34fetch(apiUrl)5 .then((response) => response.json())6 .then((data) => {7 data.forEach((crypto, index) => {8 const row = document.createElement("tr");9 row.innerHTML = `10 <td>${crypto.market_cap_rank}</td>11 <td><img src="${crypto.image}" alt="${crypto.name}" width="30" height="30"></td>12 <td>${crypto.name}</td>13 <td>${crypto.symbol.toUpperCase()}</td>14 <td>${crypto.current_price.toFixed(2)}</td>15 <td>${crypto.market_cap.toLocaleString()}</td>16 <td class="${crypto.price_change_percentage_24h >= 0 ? 'positive' : 'negative'}">${crypto.price_change_percentage_24h.toFixed(2)}</td>17 `;18 tableBody.appendChild(row);19 });20 })21 .catch((error) => {22 console.error("Error fetching data:", error);23 });1// Replace with your CoinGecko API endpoint to get the top 500 cryptocurrencies2const apiUrl = "https://api.coingecko.com/api/v3/coins/markets?vs_currency=usd...;;34fetch(apiUrl)5 .then((response) => response.json())6 .then((data) => {7 data.forEach((crypto, index) => {8 const row = document.createElement("tr");9 row.innerHTML = `10 <td>${crypto.market_cap_rank}</td>11 <td><img src="${crypto.image}" alt="${crypto.name}" width="30" height="30"></td>12 <td>${crypto.name}</td>13 <td>${crypto.symbol.toUpperCase()}</td>14 <td>${crypto.current_price.toFixed(2)}</td>15 <td>${crypto.market_cap.toLocaleString()}</td>16 <td class="${crypto.price_change_percentage_24h >= 0 ? 'positive' : 'negative'}">${crypto.price_change_percentage_24h.toFixed(2)}</td>17 `;18 tableBody.appendChild(row);19 });20 })21 .catch((error) => {22 console.error("Error fetching data:", error);23 });
});
Il faut Se connecter ou Créer un compte pour participer à cette conversation.