Skip to content

Commit

Permalink
refactor: fix lint
Browse files Browse the repository at this point in the history
  • Loading branch information
NoamGaash committed Nov 15, 2024
1 parent 01fa2fc commit d84c0fb
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/api/useVehicleLocations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -118,18 +118,18 @@ async function fetchWithQueue(url: string) {
const task = async () => {
for (let attempt = 0; attempt < 3; attempt++) {
try {
return await fetch(url);
return await fetch(url)
} catch {
if (attempt === 2) throw new Error(`Failed after 3 attempts`);
await new Promise((resolve) => setTimeout(resolve, 1000 * 2 ** attempt));
if (attempt === 2) throw new Error(`Failed after 3 attempts`)
await new Promise((resolve) => setTimeout(resolve, 1000 * 2 ** attempt))
}
}
};
}

const queue = pool.shift()!;
const result = queue.then(task).finally(() => pool.push(Promise.resolve()));
pool.push(result);
return result;
const queue = pool.shift()!
const result = queue.then(task).finally(() => pool.push(Promise.resolve()))
pool.push(result)
return result
}

// this function checks the cache for the data, and if it's not there, it loads it
Expand Down

0 comments on commit d84c0fb

Please sign in to comment.