import { toast } from 'vue-sonner'; import type { ApiResponse } from '~/types/api'; export async function registerUser( username: string, email: string, password: string ): Promise<{ success: boolean }> { const { data, error } = await useFetch>( getApiUrl('auth/register'), { method: 'POST', headers: { 'content-type': 'application/json', }, body: JSON.stringify({ name: username, email: email, password: password, }), responseType: 'json', } ); if (data.value == null) { toast.error('Register', { description: error.value?.data ?? 'Failed to register', }); return { success: false, }; } toast.success('Register', { description: `Successfully registered user ${username}`, }); return { success: true, }; }