You've already forked isop-mirror
fix: simplify error handling for FetchError in various components
This commit is contained in:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user