title: Web Fetch API (waiting the fetch to complete and then executed the next instruction)
body: <p>Is it possible to wait until the 'Fetch' instruction has completed before executing the next code/instruction? (just like how AJAX waiting works)</p>
  <p>These function are actually used to request the 'privacy value' of a post from the Facebook Graph API. How can I keep an alert prompt box from running until &quot;EVERYTHING&quot; is over (FirstRequestToGraph + RequestNextPage )</p>
  <pre><code>FirstRequestToGraph(AccessToken)
  .then(function() {
        RequestNextPage(NextPage); //recursively until there's no more next page
  })
  .then(function() {
        alert(&quot;everything has ended nicely&quot;); //still pop up before RequestNextPage Completed 
  });
  </code></pre>
  <p>_</p>
  <pre><code>function RequestNextPage(NextPage){
        fetch(NextPage, {
          method: 'GET'
        })
       .then(function(response) {
           return response.json();
        })
        .then(function(json) {
            if(json.data.length == 0 ){
             console.log(&quot;ended liao lur&quot;);
         }else{
             RequestNextPage(json.paging.next);
         }
        })
       .catch(function(err) {
           console.log(`Error: ${err}` )
        });
  }
  </code></pre>
  <p>_</p>
  <pre><code>function FirstRequestToGraph(AccessToken){
        fetch('https://graph.facebook.com/v2.8/me?fields=posts.limit(275){privacy}%2Cname&amp;access_token='+AccessToken, {
      method: 'GET'
    })
    .then(function(response) {
      return response.json();
    })
    .then(function(json){
      NextPage = json.posts.paging.next;
    })
    .catch(function(err) {
      console.log(`Error: ${err}` )
    });
  
  }
  </code></pre>