Skip to main content

Aborting Fetch

AbortController provides a new way of cancelling fetches that are no longer considered relevant. This can be hooked into fetch via the second RequestInit parameter.

Resource​

Easy integration is provided with the RestEndpoint via the signal member:

const abort = new AbortController();
const AbortableArticle = CoolerArticleResource.get.extend({
signal: abort.signal,
});
// ...somewhere later trigger cancellation
abort.abort();

Endpoint​

Any Endpoint takes a signal member the same way: read this.signal in its fetch function.