title: How can I chain up URL redirects and ensure that the user ends up on the first successful one?
body: <p>I want to chain up some redirects but also ensure that the user will go through all of them and stop on the first successful one instead of just skipping to the last one.</p>
  
  <p>My current code:</p>
  
  <pre><code>const redirect = () =&gt; {
    setTimeout(() =&gt; {
      window.location = 'https://www.google.com';
      setTimeout(() =&gt; {
        window.location = 'https://www.example.com';
      }, 1);
    }, 1);
    window.location = 'https://www.bing.com';
  };
  </code></pre>
  
  <p>If you try the above code and preserve the network log what you will see is that the first two requests (bing and google) are canceled and only the last one (example) is completed, which is also the URL you will end up to.</p>
  
  <p>What I want is to try all of them in that order and stop on the first successful one.</p>