silverwolf-x's picture
download
raw
395 Bytes
import { unstable_rethrow } from 'next/navigation'
const MAX_ATTEMPTS = 5
export const fetchRetry = async (url, init) => {
for (let i = 0; i < MAX_ATTEMPTS; i++) {
try {
return await fetch(url, init)
} catch (err) {
unstable_rethrow(err)
if (i === MAX_ATTEMPTS - 1) {
throw err
}
console.log(`Failed to fetch`, err, `retrying...`)
}
}
}

Xet Storage Details

Size:
395 Bytes
·
Xet hash:
dfb80193265610cc1b1dbe19abdaf936ddbc3e8f0dfb085626a22b7fc913dd07

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.