add a spinner in API js
Farhana Binte Hasan
Posted on December 26, 2022
Html code from bootstrap
<!-- added spinners -->
<div id="spinners" class="spinner-grow text-secondary" style="margin:10rem 40rem;" role="status">
<span class="visually-hidden">Loading...</span>
</div>
javascript code
const spinner = document.getElementById("spinners");
const loadData = () =>{
spinner.removeAttribute('hidden');
fetch('https://www.thesportsdb.com/api/v1/json/2/all_sports.php')
.then((res) => res.json())
.then((data) =>{
spinner.setAttribute('hidden', '');
displayData(data.sports)
});
}
loadData()
๐ ๐ช ๐
๐ฉ
Farhana Binte Hasan
Posted on December 26, 2022
Join Our Newsletter. No Spam, Only the good stuff.
Sign up to receive the latest update from our blog.