From a150b0c744b7193bc2e630a174315dbfb8090e04 Mon Sep 17 00:00:00 2001
From: Jonas Leder <jonas.leder@jobrouter.com>
Date: Tue, 15 Mar 2022 08:49:36 +0100
Subject: [PATCH] fix graphql using localhost for api

---
 js/customElements/blogFooter.js      | 2 +-
 js/customElements/blogIndex.js       | 2 +-
 js/customElements/commentsDisplay.js | 2 +-
 js/customElements/ebkBanner.js       | 2 +-
 js/customElements/newComment.js      | 2 +-
 js/customElements/sellingTable.js    | 2 +-
 js/viewPost.js                       | 2 +-
 public/impressum.html                | 2 +-
 8 files changed, 8 insertions(+), 8 deletions(-)

diff --git a/js/customElements/blogFooter.js b/js/customElements/blogFooter.js
index 5be26ea..14722a5 100644
--- a/js/customElements/blogFooter.js
+++ b/js/customElements/blogFooter.js
@@ -17,7 +17,7 @@ class blogFooter extends HTMLElement {
         method: 'POST',
         body: graphql,
         };
-        let posts = (await (await fetch("http://localhost:1234/API/graphql.php", requestOptions)).json()).data.blogPosts;
+        let posts = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.blogPosts;
         posts.forEach((element) => {
             let li = document.createElement("li");
             let a = document.createElement("a");
diff --git a/js/customElements/blogIndex.js b/js/customElements/blogIndex.js
index b3091b0..a1a95cf 100644
--- a/js/customElements/blogIndex.js
+++ b/js/customElements/blogIndex.js
@@ -16,7 +16,7 @@ class BlogIndex extends HTMLElement {
         method: 'POST',
         body: graphql,
         };
-        let posts = (await (await fetch("http://localhost:1234/API/graphql.php", requestOptions)).json()).data.blogPosts;
+        let posts = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.blogPosts;
         posts.forEach((element) => {
             const article = document.createElement("article");
             article.classList.add("breakWord");
diff --git a/js/customElements/commentsDisplay.js b/js/customElements/commentsDisplay.js
index 48a2c5f..e301dd1 100644
--- a/js/customElements/commentsDisplay.js
+++ b/js/customElements/commentsDisplay.js
@@ -15,7 +15,7 @@ class commentsDisplay extends HTMLElement {
         method: 'POST',
         body: graphql,
         };
-        let comments = (await (await fetch("http://localhost:1234/API/graphql.php", requestOptions)).json()).data.comments;
+        let comments = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.comments;
         this.innerHTML = "";
         comments.forEach((element) => {
             const h3 = document.createElement("h3");
diff --git a/js/customElements/ebkBanner.js b/js/customElements/ebkBanner.js
index 9ff55f3..accb1ed 100644
--- a/js/customElements/ebkBanner.js
+++ b/js/customElements/ebkBanner.js
@@ -12,7 +12,7 @@ class ebkBanner extends HTMLElement {
             method: 'POST',
             body: graphql,
         };
-        let elementCount = (await (await fetch("http://localhost:1234/API/graphql.php", requestOptions)).json()).data.ebayKleinanzeigen.count;
+        let elementCount = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.ebayKleinanzeigen.count;
         if(elementCount > 0) {
             const h2 = document.createElement("h2");
             h2.classList.add("red");
diff --git a/js/customElements/newComment.js b/js/customElements/newComment.js
index 4e8d944..0fd60c3 100644
--- a/js/customElements/newComment.js
+++ b/js/customElements/newComment.js
@@ -117,7 +117,7 @@ class newComment extends HTMLElement {
                 method: 'POST',
                 body: graphql,
                 };
-                let data = (await (await fetch("http://localhost:1234/API/graphql.php", requestOptions)).json()).data;
+                let data = (await (await fetch("/API/graphql.php", requestOptions)).json()).data;
                 if(data.newComment == "OK"){
                     document.querySelector("jl-comments_display").getComments();
                     parent.innerHTML = "<jl-new_comment></jl-new_comment>"
diff --git a/js/customElements/sellingTable.js b/js/customElements/sellingTable.js
index 53bb82d..bfd4482 100644
--- a/js/customElements/sellingTable.js
+++ b/js/customElements/sellingTable.js
@@ -60,7 +60,7 @@ class sellingTable extends HTMLElement {
             method: 'POST',
             body: graphql,
         };
-        let elements = (await (await fetch("http://localhost:1234/API/graphql.php", requestOptions)).json()).data.ebayKleinanzeigen.elements;
+        let elements = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.ebayKleinanzeigen.elements;
         elements.forEach(ad => {
             const tr = document.createElement("tr");
             table.appendChild(tr);
diff --git a/js/viewPost.js b/js/viewPost.js
index c7e3d63..dfd5dd1 100644
--- a/js/viewPost.js
+++ b/js/viewPost.js
@@ -36,7 +36,7 @@ async function loadPost() {
         method: 'POST',
         body: graphql,
         };
-        let post = (await (await fetch("http://localhost:1234/API/graphql.php", requestOptions)).json()).data.blogPost;
+        let post = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.blogPost;
         content.innerHTML = post["content"];
         document.title = post["title"] + " - Jonas Leder";
 
diff --git a/public/impressum.html b/public/impressum.html
index 55ec96f..62e7384 100644
--- a/public/impressum.html
+++ b/public/impressum.html
@@ -60,7 +60,7 @@
                 method: 'POST',
                 body: graphql,
                 };
-                let mailAddress = (await (await fetch("http://localhost:1234/API/graphql.php", requestOptions)).json()).data.mailAddress;
+                let mailAddress = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.mailAddress;
 
                 let button = document.getElementById("emailButton");
                 let emailElement = document.createElement("p");
-- 
GitLab