title: How to use gloabal variable in javascript?
body: <p>I am using JS to fetch some data through Axios. I want that response data outside the axios body. I have declared a global (let) var <code>tagData</code> outside the block. when I am logging value of <code>tagData</code> outside the axios its showing undefined.
  how can I access the <code>response.data</code> outside axios block?</p>
  
  <pre><code>let data = ""
  let tagData;
  let movie;
  
  const section = document.createElement('section');
  section.setAttribute('class', 'section');
  const container = document.createElement('div')
  container.setAttribute('class', 'container is-desktop')
  
  
  
  axios.get('https://dashletter-backend.herokuapp.com/blog/?category=allcategory')
      .then((response) =&gt; {
          tagData = response.data;
          console.log(tagData[0].name)
          for (movie in tagData) {
              const tagme = document.createElement('span')
              tagme.setAttribute('class', "tag is-rounded")
              tagme.setAttribute('id', "t" + movie)
              tagme.textContent = tagData[movie].name
              tagu.appendChild(tagme)
  
          }
      }
          , (error) =&gt; {
              console.log(error);
  
          });
  
  console.log(tagData[0].name);  // Here tagData is undefined
  </code></pre>