0Pricing
JavaScript Academy · Lesson

Aborting Requests with AbortController

Cancel in-flight requests cleanly.

Why Cancel a Request

Sometimes you start a request you no longer need: the user navigates away, types a new search, or a timeout elapses. AbortController lets you cancel an in-flight fetch.

Creating a Controller

Make an AbortController. It exposes a signal you pass to fetch and an abort() method to cancel.

const controller = new AbortController();
console.log(controller.signal); // an AbortSignal

All lessons in this course

  1. Making GET Requests
  2. POST and Sending Data
  3. Handling Errors and Status Codes
  4. Aborting Requests with AbortController
← Back to JavaScript Academy