A self-hosted media server and file management system
Vue ffmpegfile-serverjellyfinlaravelmediamedia-playermedia-servermediabrowsermediaservermusicmusic-librarymusic-playermusicplayerself-hostedvuejs
fix: uncaught error when profile doesn't exist
aminnausina5d688f252fd
diff --git a/resources/js/components/profile/ProfileHeader.vue b/resources/js/components/profile/ProfileHeader.vueindex 23e4d559..06c88815 100644--- a/resources/js/components/profile/ProfileHeader.vue+++ b/resources/js/components/profile/ProfileHeader.vue@@ -12,9 +12,15 @@ const userProfile = ref<ProfileResource>();onMounted(async () => {const userIdentifier = router.params.username.toString();- const { data } = await getProfileByName(userIdentifier);+ try {+ const { data } = await getProfileByName(userIdentifier);- userProfile.value = data;+ if (data) {+ userProfile.value = data;+ }+ } catch (error) {+ console.log(error);+ }});</script><template>diff --git a/resources/js/service/profileService.ts b/resources/js/service/profileService.tsindex 1035fea9..696af2b3 100644--- a/resources/js/service/profileService.ts+++ b/resources/js/service/profileService.ts@@ -1,6 +1,8 @@+import type { ProfileResource } from '@/types/resources';+import { API } from '@/service/api';-export async function getProfileByName(username: string) {+export async function getProfileByName(username: string): Promise<{ data: ProfileResource | null }> {const parsedId = parseInt(username);if (!isNaN(parsedId) && parsedId.toString() === username) return getProfileById(parsedId);@@ -8,7 +10,7 @@ export async function getProfileByName(username: string) {return data ?? null;}-export async function getProfileById(id: number) {+export async function getProfileById(id: number): Promise<{ data: ProfileResource | null }> {const { data } = await API.get(`/profiles/${id}`);return data ?? null;}