From 7b56fbbdcd4ac99130be03a3d0cbdf69e4003aec Mon Sep 17 00:00:00 2001 From: Jonas Leder Date: Thu, 7 Apr 2022 09:24:06 +0200 Subject: [PATCH] set content type in graphql request --- js/customElements/blogFooter.js | 1 + js/customElements/blogIndex.js | 1 + js/customElements/commentsDisplay.js | 1 + js/customElements/contactMailButton.js | 1 + js/customElements/ebkBanner.js | 1 + js/customElements/newComment.js | 2 ++ js/customElements/sellingTable.js | 1 + js/customElements/skills.js | 1 + js/viewPost.js | 1 + public/API/graphql.php | 5 +++-- public/impressum.html | 1 + 11 files changed, 14 insertions(+), 2 deletions(-) diff --git a/js/customElements/blogFooter.js b/js/customElements/blogFooter.js index 999f635..7d11c41 100644 --- a/js/customElements/blogFooter.js +++ b/js/customElements/blogFooter.js @@ -15,6 +15,7 @@ class blogFooter extends HTMLElement { var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let posts = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.blogPosts; posts.forEach((element) => { diff --git a/js/customElements/blogIndex.js b/js/customElements/blogIndex.js index a1a95cf..342f08c 100644 --- a/js/customElements/blogIndex.js +++ b/js/customElements/blogIndex.js @@ -15,6 +15,7 @@ class BlogIndex extends HTMLElement { var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let posts = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.blogPosts; posts.forEach((element) => { diff --git a/js/customElements/commentsDisplay.js b/js/customElements/commentsDisplay.js index e301dd1..3243502 100644 --- a/js/customElements/commentsDisplay.js +++ b/js/customElements/commentsDisplay.js @@ -14,6 +14,7 @@ class commentsDisplay extends HTMLElement { var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let comments = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.comments; this.innerHTML = ""; diff --git a/js/customElements/contactMailButton.js b/js/customElements/contactMailButton.js index 5d1aa17..b1f138f 100644 --- a/js/customElements/contactMailButton.js +++ b/js/customElements/contactMailButton.js @@ -12,6 +12,7 @@ class contactMailButton extends HTMLElement { var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let sitekey = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.sitekey; diff --git a/js/customElements/ebkBanner.js b/js/customElements/ebkBanner.js index 2818b20..2171dd3 100644 --- a/js/customElements/ebkBanner.js +++ b/js/customElements/ebkBanner.js @@ -11,6 +11,7 @@ class ebkBanner extends HTMLElement { var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let elementCount = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.ebayKleinanzeigen.count; if(elementCount > 0) { diff --git a/js/customElements/newComment.js b/js/customElements/newComment.js index 54f0e4b..b7c372f 100644 --- a/js/customElements/newComment.js +++ b/js/customElements/newComment.js @@ -15,6 +15,7 @@ class newComment extends HTMLElement { var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let sitekey = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.sitekey; @@ -117,6 +118,7 @@ class newComment extends HTMLElement { var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let data = (await (await fetch("/API/graphql.php", requestOptions)).json()).data; if (data.newComment == "OK") { diff --git a/js/customElements/sellingTable.js b/js/customElements/sellingTable.js index bfd4482..c9c11a6 100644 --- a/js/customElements/sellingTable.js +++ b/js/customElements/sellingTable.js @@ -59,6 +59,7 @@ class sellingTable extends HTMLElement { var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let elements = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.ebayKleinanzeigen.elements; elements.forEach(ad => { diff --git a/js/customElements/skills.js b/js/customElements/skills.js index c37631b..383952a 100644 --- a/js/customElements/skills.js +++ b/js/customElements/skills.js @@ -11,6 +11,7 @@ class Skill extends HTMLElement { var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let skills = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.skills; diff --git a/js/viewPost.js b/js/viewPost.js index be5bda8..15e8261 100644 --- a/js/viewPost.js +++ b/js/viewPost.js @@ -29,6 +29,7 @@ async function loadPost() { var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let post = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.blogPost; content.innerHTML = post["content"]; diff --git a/public/API/graphql.php b/public/API/graphql.php index 0e8190a..b778f21 100644 --- a/public/API/graphql.php +++ b/public/API/graphql.php @@ -1,5 +1,5 @@ $queryType + 'query' => $queryType, + 'mutation' => $mutationType, ]); try { diff --git a/public/impressum.html b/public/impressum.html index 62e7384..c8246cd 100644 --- a/public/impressum.html +++ b/public/impressum.html @@ -59,6 +59,7 @@ var requestOptions = { method: 'POST', body: graphql, + headers: { 'Content-Type': 'application/json' } }; let mailAddress = (await (await fetch("/API/graphql.php", requestOptions)).json()).data.mailAddress;