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.
77```
88import timeoutSignal from 'timeout-signal';
99
10+ const signal = timeoutSignal(5000);
11+
1012try {
11- const response = await fetch('https://www.google.com', {signal: timeoutSignal(5000) });
13+ const response = await fetch('https://www.google.com', {signal});
1214 // Handle response
1315} catch (error) {
1416 if (signal.aborted) {
Original file line number Diff line number Diff line change @@ -13,8 +13,10 @@ npm install timeout-signal
1313``` js
1414import timeoutSignal from ' timeout-signal' ;
1515
16+ const signal = timeoutSignal (5000 );
17+
1618try {
17- const response = await fetch (' https://www.google.com' , {signal: timeoutSignal ( 5000 ) });
19+ const response = await fetch (' https://www.google.com' , {signal});
1820 // Handle response
1921} catch (error) {
2022 if (signal .aborted ) {
You can’t perform that action at this time.
0 commit comments