From 4ed4d3a26fadffd96b019b0dd9909e0b1753e9e5 Mon Sep 17 00:00:00 2001 From: Adam French Date: Tue, 20 Jan 2026 20:27:24 +0000 Subject: [PATCH] fix too many v-if --- nginx/vue/src/components/home/Feed.vue | 49 ++++++++---------- nginx/vue/src/components/home/Gym.vue | 26 ++++------ nginx/vue/src/components/home/Listening.vue | 55 +++++++++++---------- 3 files changed, 60 insertions(+), 70 deletions(-) diff --git a/nginx/vue/src/components/home/Feed.vue b/nginx/vue/src/components/home/Feed.vue index 08ef4ca..f6c027e 100644 --- a/nginx/vue/src/components/home/Feed.vue +++ b/nginx/vue/src/components/home/Feed.vue @@ -8,7 +8,15 @@ import { useAuthStore } from "@/stores/auth"; const auth = useAuthStore(); const userOwnsPost = ref(false); -const post = ref(null); +const post = ref({ + title: "Can't fetch from the db yo", + content: + "This is meant to be pulling from a database, but for some reason that isn't working and this is filler text that should hopefully never see the light of day. If you are reading this, something has gone horribly, horribly wrong. Please start crying and prepare for the incoming wrath of hell. Furthermore, this is very, very long because I am trying to test the scroll feature so thank you ^_^.", + author: { + username: "stp", + }, + createdAt: Date.now(), +}); const leftCap = ref(false); const rightCap = ref(false); let posts = []; @@ -17,14 +25,17 @@ let len = 0; async function fetchPosts() { try { - const res = await axios.get("https://www.adam-french.co.uk/api/posts"); - posts = res.data; - len = posts.length; - post.value = posts[0]; - - userOwnsPost.value = post.value.author.username == auth.user.username; - - leftCap.value = true; + const res = await axios.get("/api/posts"); + if (Array.isArray(res.data)) { + posts = res.data; + len = posts.length; + post.value = posts[0]; + userOwnsPost.value = + post.value.author.username == auth.user.username; + leftCap.value = true; + } else { + throw new Error("Invalid response from API"); + } } catch (err) { console.log("Cannot connect to API"); } @@ -66,7 +77,7 @@ onMounted(() => {