Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
export async function tryFetch(url: string) {
while (!navigator.onLine) {
console.error("you're offline, retrying...")
await delay(1000)
}
const response = await fetch(proxify(url, 'latin1'))
if (response.status !== 200) {
throw new Error(`${url}: ${response.status}`)
}
const text = await response.text()
if (text.includes('<title>404 Not Found</title>')) {
// stupid me
throw new Error(`${url}: 404`)
}
return text
}async function tryFetch(url: string) {
while (!navigator.onLine) {
console.error("you're offline, retrying...")
await delay(1000)
}
const text = await proxy(url, 'latin1')
if (text.includes('<title>404 Not Found</title>')) {
// stupid me
throw new Error(`${url}: 404`)
}
return text
}// stage,
season,
})
setPopup({
waiting: false,
error: null,
})
} catch (err) {
console.error(err)
setPopup({
waiting: false,
error: 'Could not fetch data',
})
await delay(1000)
const {
tournament: newTournament,
stage: newStage,
} = params
const newSeason = pots && season !== currentSeasonByTournament(newTournament, newStage)
? season
: undefined
onSeasonChange(newTournament, newStage, newSeason)
setPopup({
error: null,
})
}
}export default async (sourceCell: HTMLElement, targetCell: HTMLElement, duration: number) => {
const fakeCell = makeFakeCell(sourceCell)
airborneDiv.appendChild(fakeCell)
const targetCellBox = targetCell.getBoundingClientRect()
fakeCell.style.transition = `transform ${duration}ms ease-in-out`
adjustPositioning(fakeCell, targetCellBox)
await transitionEnd(fakeCell)
if (isFirefox) {
await delay(0)
}
airborneDiv.removeChild(fakeCell)
}const runCalculatingTimer = async (oldValue: T) => {
dispatchLongCalculating({
type: types.set,
payload: oldValue,
})
await delay(delayMs)
dispatchLongCalculating({
type: types.set,
payload: oldValue,
})
}