AbortController can be used to cancel multiple request
Let's say the user clicks a link while we are still loading some data. Then we can use
AbortController
, a controller object that allows us to abort one or more web requests, to tell the browser to cancel and ignore the request.const { signal } = new AbortController();
// Pass the same signal to multiple promises
fetch('url-one', { signal });
fetch('url-two', { signal });
// Cancel all requests
controller.abort();