title: How to write fetch synchronously?
body: <p>I'm new in javascript/typescript I write blackjack app using typescript and in one player game I have bot as second player.
  His script looks like this:</p>
  <pre class="lang-js prettyprint-override"><code>        const botTurn = (bot : Player) =&gt;{
              while(bot.Points &lt; 21)
              {
                  if(bot.Points &lt; 18)
                  {
                      hitMe();
                  }
                  else
                  {
                      var random = Math.random();
                      if(random &lt; 0.5)
                      {
                          hitMe();
                      }
                      else{
                          break;
                      }
                  }
              }
  
              stay();
          }
  </code></pre>
  <p>and hitMe looks like this:</p>
  <pre class="lang-js prettyprint-override"><code>        const hitMe = () =&gt;
          {
              fetch('https://deckofcardsapi.com/api/deck/' + deckId + '/draw/?count=1')
              .then(response =&gt; response.json())
              .then(data =&gt; {
                  deckLenght = data.remaining;
                  for(let card of data.cards)
                  {
                      var newCard = getCardData(card);
                      players[currentPlayer].Hand.push(newCard);
                      renderCard(newCard, currentPlayer);
                      updatePoints();
                      updateDeckLenght();
                      check();
                  }
              });
          }
  </code></pre>
  <p>So botTurn doesn't wait for hitMe to finish and my browser hangs
  How to fix that?</p>