Skip to content

Commit

Permalink
HttpUtils - fetch with timeout
Browse files Browse the repository at this point in the history
  • Loading branch information
jmaur-bndes committed Mar 30, 2023
1 parent 98d961a commit 5135309
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/lib/utils/http_utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ export default class HttpUtils {
log.debug(`FETCH ${url} - GET`)
for (let t = 1; t <= tries; t++) {
try {
let response = await fetch(url)
const c = new AbortController();
const id = setTimeout(() => c.abort(), 1000);
let response = await fetch(url, {signal: c.signal});
clearTimeout(id);

if (response) {
log.debug(`FETCH ${url} - RESP - STATUS ${response.status} - ${response.statusText}`)
Expand Down

0 comments on commit 5135309

Please sign in to comment.