Skip to content
Snippets Groups Projects
Commit 0a322725 authored by Anders Høvik's avatar Anders Høvik
Browse files

Fix: fixed missing try-catch in myProfile.

parent 4e3fb5ff
No related branches found
No related tags found
1 merge request!86Feature/history endpoint
Pipeline #283706 failed
<script setup lang="ts"> <script setup lang="ts">
import {ref, onMounted, type Ref, type UnwrapRef} from "vue"; import {ref, onMounted} from "vue";
import { useRouter } from "vue-router"; import { useRouter } from "vue-router";
import { useUserInfoStore } from "../../stores/UserStore"; import { useUserInfoStore } from "@/stores/UserStore";
import {UserService, BadgeService, GoalService, type GoalDTO} from "@/api"; import {UserService, BadgeService, GoalService, type GoalDTO, type BadgeDTO} from "@/api";
import { ItemService } from "@/api"; import { ItemService } from "@/api";
let numberOfHistory = 6; let numberOfHistory = 6;
...@@ -15,7 +15,7 @@ let hasHistory = ref(true) ...@@ -15,7 +15,7 @@ let hasHistory = ref(true)
const router = useRouter(); const router = useRouter();
const inventory = ref([] as any); const inventory = ref([] as any);
const badges = ref([] as any); const badges = ref<BadgeDTO[]>([]);
const backgroundName = ref(""); const backgroundName = ref("");
...@@ -27,17 +27,18 @@ let createdAt = ref(''); ...@@ -27,17 +27,18 @@ let createdAt = ref('');
let goals = ref<GoalDTO[]>([]) let goals = ref<GoalDTO[]>([])
async function getGoals() { async function getGoals() {
goals.value = await GoalService.getGoals(); try {
console.log("number of goals: ", goals.value.length ) goals.value = await GoalService.getGoals();
console.log('The id of a goal: ', goals.value[0]) console.log("number of goals: ", goals.value.length)
if(goals.value.length > 0) { console.log('The id of a goal: ', goals.value[0])
hasHistory.value = true if (goals.value.length > 0) {
hasHistory.value = true
} else {
hasHistory.value = false
}else{ console.log('No history')
hasHistory.value = false }
console.log('No history') }catch (error){
console.error("Something went wrong", error)
} }
} }
...@@ -85,6 +86,7 @@ const selectItem = (item: any) => { ...@@ -85,6 +86,7 @@ const selectItem = (item: any) => {
onMounted(() => { onMounted(() => {
setupForm() setupForm()
getGoals()
}) })
const toRoadmap = () => { const toRoadmap = () => {
...@@ -98,9 +100,6 @@ const toUpdateUserSettings = () => { ...@@ -98,9 +100,6 @@ const toUpdateUserSettings = () => {
router.push('/settings/profile'); router.push('/settings/profile');
}; };
onMounted(()=>{
getGoals()
})
</script> </script>
...@@ -279,7 +278,7 @@ onMounted(()=>{ ...@@ -279,7 +278,7 @@ onMounted(()=>{
} }
#banner { #banner {
background-image: url('../src/assets/banners/stacked.svg'); background-image: url('/src/assets/banners/stacked.svg');
} }
.card-1 { .card-1 {
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment