This commit is contained in:
2025-12-19 17:15:05 -05:00
parent faae6ac0f6
commit 79d2055159
5 changed files with 88 additions and 83 deletions

View File

@@ -3,6 +3,26 @@
* Note: These utilities should only run in the browser
*/
/**
* Safe fetch wrapper that suppresses console errors for expected 401 responses
* Use this instead of direct fetch() calls when 401s are expected (e.g., auth checks)
* @param input - URL or Request object
* @param init - Fetch options
* @returns Promise<Response>
*/
export async function safeFetch(
input: RequestInfo | URL,
init?: RequestInit
): Promise<Response> {
try {
const response = await fetch(input, init);
return response;
} catch (error) {
// Re-throw the error - this is for actual network failures
throw error;
}
}
/**
* Triggers haptic feedback on mobile devices
* @param duration - Duration in milliseconds (default 50ms for a light tap)