Skip to content

Commit

Permalink
fix() : url path issue solved
Browse files Browse the repository at this point in the history
  • Loading branch information
raiyanu committed May 25, 2024
1 parent f894592 commit c4ae6cf
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions js/content-loader.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
async function fetchContentData() {
async function fetchContentData(dataPath) {
try {
const response = await fetch("../data.json");
const response = await fetch(dataPath);
if (!response.ok) {
throw new Error("Network response was not ok");
}
Expand All @@ -9,9 +9,13 @@ async function fetchContentData() {
appendMenuData(menuData);
} catch (error) {
console.error("Fetch error:", error);
if (errCount == 0) {
fetchContentData("/foodie-site/data.json");
errCount++;
}
}
}

let errCount = 0;
function appendMenuData(data) {
const main = document.querySelector("main");

Expand Down Expand Up @@ -68,6 +72,6 @@ function appendMenuData(data) {
}

document.addEventListener("DOMContentLoaded", async function () {
await fetchContentData();
await fetchContentData("../data.json");
await masonry_init();
});

0 comments on commit c4ae6cf

Please sign in to comment.