Skip to content

Commit

Permalink
Move timeoutId out of try-catch scope in Abort example (#28112)
Browse files Browse the repository at this point in the history
  • Loading branch information
Sebdevar authored Jul 22, 2023
1 parent 102d404 commit 203d1f3
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion files/en-us/web/api/abortsignal/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,10 @@ To trigger on multiple signals they must be daisy chained.
The code snippet below shows how you might call {{domxref("AbortController.abort()")}} in the handler for a separate timer.

```js
let timeoutId;
try {
const controller = new AbortController();
const timeoutId = setTimeout(() => controller.abort(), 5000);
timeoutId = setTimeout(() => controller.abort(), 5000);
const res = await fetch(url, { signal: controller.signal });
const body = await res.json();
} catch (e) {
Expand Down

0 comments on commit 203d1f3

Please sign in to comment.