File tree Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Expand file tree Collapse file tree 2 files changed +6
-2
lines changed Original file line number Diff line number Diff line change @@ -7,8 +7,10 @@ Create an AbortSignal that aborts after a delay.
7
7
```
8
8
import timeoutSignal from 'timeout-signal';
9
9
10
+ const signal = timeoutSignal(5000);
11
+
10
12
try {
11
- const response = await fetch('https://www.google.com', {signal: timeoutSignal(5000) });
13
+ const response = await fetch('https://www.google.com', {signal});
12
14
// Handle response
13
15
} catch (error) {
14
16
if (signal.aborted) {
Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ npm install timeout-signal
13
13
``` js
14
14
import timeoutSignal from ' timeout-signal' ;
15
15
16
+ const signal = timeoutSignal (5000 );
17
+
16
18
try {
17
- const response = await fetch (' https://www.google.com' , {signal: timeoutSignal ( 5000 ) });
19
+ const response = await fetch (' https://www.google.com' , {signal});
18
20
// Handle response
19
21
} catch (error) {
20
22
if (signal .aborted ) {
You can’t perform that action at this time.
0 commit comments