title: Why does async function return undefined?
body: <p>Basically I have an async function that fetches data from the pokeAPI. I go through the data and extract what I need then I want to store that data in a variable for future use. My problem is that once I come out of the function it seems that all the data is undefined however while inside the function the data clearly shows that it is being stored like I want it to be. I've exhausted all possible ideas I can think of for fixing or understanding the problem and am at my wits end here.</p>
  <pre><code>const getAllPokemon = async () =&gt; {
    try {
      const arr = [];
      const response = await fetch(&quot;https://pokeapi.co/api/v2/pokemon?limit=5&quot;);
      const data = await response.json();
      const pokeResults = data.results;
      for (let pokemon of pokeResults) {
        arr.push(getPokemonData(pokemon));
      }
      return arr;
    } catch (e) {
      return &quot;Unable to find pokemon&quot;;
    }
  };
  
  const getPokemonData = async (pokemon) =&gt; {
    let url = pokemon.url;
    const response = await fetch(url);
    const data = await response.json();
    let pokeObj = new Object();
    pokeObj.name = data.forms[0].name;
    pokeObj.id = data.id;
    return pokeObj;
  };
  
  
  const pokemon = getAllPokemon();
  console.log(pokemon);
  </code></pre>