From 18ac3b917329371477d0c351d51d5eb899d0c6f8 Mon Sep 17 00:00:00 2001 From: isUnknown Date: Tue, 10 Sep 2024 08:13:20 +0200 Subject: [PATCH] api - fix url fetch --- src/stores/api.js | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/src/stores/api.js b/src/stores/api.js index acbc4b7..fcac154 100644 --- a/src/stores/api.js +++ b/src/stores/api.js @@ -31,13 +31,11 @@ export const useApiStore = defineStore("counter", () => { * }); */ async function fetchPageData(path = window.location.pathname) { - - // TODO: Fix url for Home AND Inspirations - const isHomePage = path === "/"; - const url = isHomePage - ? `${window.location.origin}/home.json` - : `${window.location.origin}${path}.json`; + path = isHomePage ? "/home" : path; + path = path.startsWith("/") ? path : "/" + path; + + const url = `${window.location.origin}${path}.json`; try { const response = await fetch(url);