add a spinner in API js

farhanacsebd

Farhana Binte Hasan

Posted on December 26, 2022

add a spinner in API js

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>
Enter fullscreen mode Exit fullscreen mode

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()
Enter fullscreen mode Exit fullscreen mode
๐Ÿ’– ๐Ÿ’ช ๐Ÿ™… ๐Ÿšฉ
farhanacsebd
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.

Related

ยฉ TheLazy.dev

About