Files
cnapp/src/utils.ts
T
nikolark fc8e6c9745 Fix last typescript strict issues
This uses the `any` escape hatch a few more places, which should be tidied up later.
Suggest upgrading redux usage to the latest version and start using slices to make a few things easier. Also the confetti component might be worth replacing

Remove dead code from the old membership charge flow++
2024-07-07 22:33:57 +02:00

17 lines
499 B
TypeScript

export function snakeToCamelCase(val: string): string {
return val.replace(/_([a-z])/g, (g) => g[1].toUpperCase());
}
export function fetchWithTimeout(url: string, options?: RequestInit, timeout = 10000) {
/** Wraps fetch to allow it to time out */
// FIXME: show timeout message in UI
return Promise.race([
fetch(url, options),
new Promise<Response>((_, reject) => {
setTimeout(() => {
reject(new Error('Fetch request timed out'));
}, timeout);
}),
]);
}