interface ApiErrorLike { status?: number statusCode?: number statusMessage?: string message?: string data?: { error?: { message?: string; code?: string } message?: string } } /** Human-readable message from a Nuxt/$fetch error, without leaking tokens. */ export function apiErrorMessage(error: unknown, fallback: string): string { const value = error as ApiErrorLike | undefined return ( value?.data?.error?.message ?? value?.data?.message ?? value?.statusMessage ?? value?.message ?? fallback ) } export function apiErrorStatus(error: unknown): number | undefined { const value = error as ApiErrorLike | undefined return value?.status ?? value?.statusCode }