AbortController can be used to cancel multiple request

tags: [[Development]], [[React]]

pid: 210622110339

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

[[Ryan Florence]]. ([[2021-06-21]]). "AbortController". Link
[[MDN]]. AbortController. Link
Linked references