export async function patientFetchJSON( url: string, timeout = 1000, options?: Partial<{ cache: 'no-store' }>, ) { let patientJSON: Type; while (patientJSON! === undefined) { try { patientJSON = (await fetch(url, options).then((response) => response.json(), )) as Type; } catch (error) { console.warn( `Failed to fetch ${url} as JSON; retrying in ${timeout}ms...`, error, ); await new Promise((resolve) => setTimeout(resolve, timeout)); } } return patientJSON; }