title: Data not rendering after OnCLick
body: <p>I am trying to display the data after hitting the &quot;Show the data&quot; button. I can see the data in the console but it is not being display on the page. Could anyone help me out and guide me to let me know what is my mistake. Been struggling for days now. Below is my code. I have edited critical information in the code for obvious security reasons. Any help would be appreciated. Thank you.</p>
  <p>axios.post is used to post the token and
  axios.get is used to fetch the data from the backend and display it.</p>
  <hr />
  <pre><code>
  
  import {useState} from 'react';
  import axios from 'axios';
  import '../App.css'
  
  var raw = JSON.stringify({
    
    username: &quot;xyz&quot;,
    password: &quot;xyz&quot;
  });
  
  const type_no = '88'; 
  
  const URL = `example url://abc.com/abc/${type_no}`;
  
  
  
  
  function getToken(){
    const promise = axios.post(&quot;example url://abc.com/&quot;, raw)
    const id = promise.then((response) =&gt; response.data.IdToken)
    return id
   };
  
  const App = () =&gt; {
    const [data, setData] = useState({data: []});
    const [isLoading, setIsLoading] = useState(false);
    const [err, setErr] = useState('');
  
  
  
  
     const handleClick = async () =&gt; {
      getToken().then(token =&gt; {
  
          setIsLoading(true);
          
            const config = {
              headers: {
                'Authorization': 'Bearer ' + token,
                'Content-Type': 'application/json',
              }
            };
            const {data} = axios.get(URL, config)
              .then((response) =&gt; {
                console.log(response);
                setData(response.data);
               
               
              })
              .catch((error) =&gt; {
                console.log(error);
              });
              setIsLoading(false)
        
  
          
      })
  
      
    
  
    };
    
  
    
  
    
  
    
  
    console.log('Data: ', JSON.stringify(data,null,4));   
  
    
  
    return (
      &lt;div className=&quot;form&quot;&gt;
        {err &amp;&amp; &lt;h2&gt;{err}&lt;/h2&gt;}
  
        &lt;button onClick={handleClick}&gt;Show the data&lt;/button&gt;
  
        {isLoading &amp;&amp; &lt;h2&gt;Loading data...&lt;/h2&gt;}  
  
        {data.data?.map(data =&gt; {
          return (
            
            &lt;div key={data.id}&gt;
              &lt;h2&gt;{data.email}&lt;/h2&gt;
              &lt;h2&gt;{data.first_name}&lt;/h2&gt;
              &lt;h2&gt;{data.last_name}&lt;/h2&gt;
              &lt;br /&gt;
            &lt;/div&gt;
          );
        })}
      &lt;/div&gt;
    );
  
    
  };
  
  export default App;
  
  </code></pre>