title: How to cancel network requests in JS?
body: <p><a href="https://reactjs.org/docs/react-component.html#componentwillunmount" rel="nofollow noreferrer">The React documentation for <code>componentWillUnmount()</code></a> implies that it is possible to <em>cancel network requests</em>:</p>
  
  <blockquote>
    <p>Perform any necessary cleanup in this method, such as invalidating timers, <strong>canceling network requests</strong>, ...</p>
  </blockquote>
  
  <p>But <a href="https://stackoverflow.com/questions/31061838/how-do-i-cancel-an-http-fetch-request">answers here</a> say it is not possible.</p>
  
  <p>Question being, is it possible or not to cancel a network requests in JS?</p>
  
  <p>For example, if I started a <code>setInterval</code> to requests using the Fetch API in <code>componentDidMount</code>, and on some condition I want to stop requests, doing so in <code>componentWillUnmount</code> per the documentation. How can I cancel all network requests? I'm not talking about calling <code>clearInterval</code>, which will stop the timer. I want to make sure that any network requests that were started will be canceled in a given condition.</p>