I am completely inexperienced with JavaScript but I am working on a website that needs to pull updated stats from an API. After doing some reading and following a few tutorials, I'm still pretty lost. Any help would be appreciated.
Here is what I have and it's not working and I'm not sure if I'm even on the right path.
JS
const api_url = 'https://plutonium.pw/api/stats'
async function getData() {
const response = await fetch(api_url);
const data = await response.json();
const { bans } = data;
document.getElementById("bans").textContent = bans;
console.log(bans);
}
getData();
HTML
<!doctype html>
<html>
<head>
<title>Test Page</title>
</head>
<body>
<p>bans: <span id="bans"></span></p>
</body>
</html>