async await for fetching data with spinner in javascript [source code] given below-


Answer:

Script will look like:

const getMeta = async () => {
    try {
      let URL = `${externalUrl}`
      spinner.src = "/assets/images/Spinner-2.gif"
      // inside spinner src u put your own loader
      await axios.get(URL)
      .then(response => {
      spinner.src = ""
      console.log(response);
      //response can append inside any html elements.
      })
    } catch (error) {
      console.log(error)
    }
  }

If you have no any amazing loader and spinner then please visit this site -

PREVIEW: https://icons8.com/preloaders/

Trust me! you will get best loader that you want for your amazing sites.

some cool loaders preview:

Hopefully, If you get your answer, then please share this post with your technical friends.