api - fix url fetch
This commit is contained in:
parent
550da7fb47
commit
18ac3b9173
1 changed files with 4 additions and 6 deletions
|
|
@ -31,13 +31,11 @@ export const useApiStore = defineStore("counter", () => {
|
||||||
* });
|
* });
|
||||||
*/
|
*/
|
||||||
async function fetchPageData(path = window.location.pathname) {
|
async function fetchPageData(path = window.location.pathname) {
|
||||||
|
|
||||||
// TODO: Fix url for Home AND Inspirations
|
|
||||||
|
|
||||||
const isHomePage = path === "/";
|
const isHomePage = path === "/";
|
||||||
const url = isHomePage
|
path = isHomePage ? "/home" : path;
|
||||||
? `${window.location.origin}/home.json`
|
path = path.startsWith("/") ? path : "/" + path;
|
||||||
: `${window.location.origin}${path}.json`;
|
|
||||||
|
const url = `${window.location.origin}${path}.json`;
|
||||||
|
|
||||||
try {
|
try {
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue