title: Unhandled promise rejection TypeError
body: <p>I'm using async/await to make a query to database and get the result, but I don't know why I've got this error in browser console:</p>
  
  <blockquote>
    <p>Unhandled promise rejection TypeError: "games is undefined"</p>
  </blockquote>
  
  <p>I've got two functions, getData which is async and make a call to getGames:</p>
  
  <pre><code>getGames(){
      let query = HOMELF1_NEXT_GAMES;
      var data = {
          "query": query,
          "variables": null
      }
      fetch(URL_FEB_API, {
          method: "POST",
          headers: {
              "Accept"        :   "application/json",
              "content-type"  :   "application/json"
          },
          body: JSON.stringify(data)
      })
      .then(response =&gt; {
          return response.json()
      })
      .then(data =&gt; {
          console.log("End query");
          return data;
      })
      .catch(err =&gt; {
          console.log("Error: " + err)
      })
  }
  
  async getData(){
      console.log("Before getGames");
      let games = await this.getGames();
      console.log("After getGames");
      console.log("games: " + games.length)
  }
  
  componentDidMount(){
      this.getData();
  };
  </code></pre>
  
  <p>And in browser console I've got this result:</p>
  
  <p><a href="https://i.stack.imgur.com/fevSy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fevSy.png" alt="enter image description here"></a></p>
  
  <p>Why is not working here async/await? What am I doing wrong?</p>