From 0a322725b7ee7a5f72094aaf32fdff99d53582e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anders=20H=C3=B8vik?= <andehovi@stud.ntnu.no> Date: Thu, 2 May 2024 18:12:07 +0200 Subject: [PATCH] Fix: fixed missing try-catch in myProfile. --- src/components/UserProfile/MyProfile.vue | 37 ++++++++++++------------ 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/src/components/UserProfile/MyProfile.vue b/src/components/UserProfile/MyProfile.vue index 20a91b9..e28506e 100644 --- a/src/components/UserProfile/MyProfile.vue +++ b/src/components/UserProfile/MyProfile.vue @@ -1,8 +1,8 @@ <script setup lang="ts"> -import {ref, onMounted, type Ref, type UnwrapRef} from "vue"; +import {ref, onMounted} from "vue"; import { useRouter } from "vue-router"; -import { useUserInfoStore } from "../../stores/UserStore"; -import {UserService, BadgeService, GoalService, type GoalDTO} from "@/api"; +import { useUserInfoStore } from "@/stores/UserStore"; +import {UserService, BadgeService, GoalService, type GoalDTO, type BadgeDTO} from "@/api"; import { ItemService } from "@/api"; let numberOfHistory = 6; @@ -15,7 +15,7 @@ let hasHistory = ref(true) const router = useRouter(); const inventory = ref([] as any); -const badges = ref([] as any); +const badges = ref<BadgeDTO[]>([]); const backgroundName = ref(""); @@ -27,17 +27,18 @@ let createdAt = ref(''); let goals = ref<GoalDTO[]>([]) async function getGoals() { - goals.value = await GoalService.getGoals(); - console.log("number of goals: ", goals.value.length ) - console.log('The id of a goal: ', goals.value[0]) - if(goals.value.length > 0) { - hasHistory.value = true - - - - }else{ - hasHistory.value = false - console.log('No history') + try { + goals.value = await GoalService.getGoals(); + console.log("number of goals: ", goals.value.length) + console.log('The id of a goal: ', goals.value[0]) + if (goals.value.length > 0) { + hasHistory.value = true + } else { + hasHistory.value = false + console.log('No history') + } + }catch (error){ + console.error("Something went wrong", error) } } @@ -85,6 +86,7 @@ const selectItem = (item: any) => { onMounted(() => { setupForm() + getGoals() }) const toRoadmap = () => { @@ -98,9 +100,6 @@ const toUpdateUserSettings = () => { router.push('/settings/profile'); }; -onMounted(()=>{ - getGoals() -}) </script> @@ -279,7 +278,7 @@ onMounted(()=>{ } #banner { - background-image: url('../src/assets/banners/stacked.svg'); + background-image: url('/src/assets/banners/stacked.svg'); } .card-1 { -- GitLab