fix: simplify error handling for FetchError in various components

This commit is contained in:
2025-11-08 14:06:51 +01:00
parent df78942ede
commit 708bd79200
8 changed files with 24 additions and 14 deletions

View File

@@ -1,6 +1,7 @@
<script setup lang="ts">
import { NewRole } from '~/types/role';
import type { NewUser } from '~/types/user';
import { FetchError } from 'ofetch';
definePageMeta({
middleware: ['sanctum:guest'],
@@ -63,8 +64,10 @@ async function handleRegistration() {
});
navigateTo("/");
} catch (e: any) {
error.value = e.data?.message as string;
} catch (e) {
if (e instanceof FetchError) {
error.value = e.response?._data.message;
}
} finally {
loading.value = false;
}