title: I can't access the data stored in my sessionDates array in my DateList function
body: <p>I can't access the data stored in my sessionDates array in my DateList function</p>
  <p>this is the code from my index.js including the api call</p>
  <pre><code>import React from &quot;react&quot;;
  import ReactDOM from &quot;react-dom&quot;;
  const availableDates = [];
  const available = [];
  const sessionDates = [];
  
  function getDates(e){
    getDate(apiUrl);
  }
  
  const getDate = async (apiUrl)=&gt;{
    const res = await fetch(apiUrl)
    try {
      const data = await res.json();
      availableDates.push(data);
      availableDates.map((datee) =&gt; {
        datee.map((session) =&gt; {
          sessionDates.push(session.date.slice(0, 10));
        });
      });
      return sessionDates;
    }  catch(error) {
      console.log(&quot;error&quot;, error);
    }
  }
  window.addEventListener('load', getDates);
  
  function DateList(){
    return &lt;section&gt;{sessionDates[0]}&lt;/section&gt;;
  }
  </code></pre>