You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: 5-network/04-fetch-abort/article.md
+25-14
Original file line number
Diff line number
Diff line change
@@ -1,9 +1,9 @@
1
1
2
2
# Fetch: Abort
3
3
4
-
Aborting a `fetch` is a little bit tricky. Remember, `fetch` returns a promise. And JavaScript generally has no concept of "aborting" a promise. So how can we cancel a fetch?
4
+
As we know, `fetch` returns a promise. And JavaScript generally has no concept of "aborting" a promise. So how can we abort a `fetch`?
5
5
6
-
There's a special built-in object for such purposes: `AbortController`.
6
+
There's a special built-in object for such purposes: `AbortController`, that can be used to abort not only `fetch`, but other asynchronous tasks as well.
7
7
8
8
The usage is pretty simple:
9
9
@@ -13,9 +13,16 @@ The usage is pretty simple:
13
13
let controller =newAbortController();
14
14
```
15
15
16
-
A controller is an extremely simple object.It has a single method `abort()`, and a single property `signal`. When`abort()` is called, the `abort`event triggers on `controller.signal`:
16
+
A controller is an extremely simple object.
17
17
18
-
Like this:
18
+
- It has a single method `abort()`, and a single property `signal`.
0 commit comments