diff --git a/js/viewPost.js b/js/viewPost.js index 01241e9..3c55634 100644 --- a/js/viewPost.js +++ b/js/viewPost.js @@ -26,7 +26,15 @@ async function loadPost() { if(id == null) { content.innerHTML = "

404 - Post not found

"; } else { - let post = await (await fetch("/API/getPost.php?id=" + id)).json(); + var graphql = JSON.stringify({ + query: 'query {blogPost(id: "' + id + '") {content title}}', + variables: {} + }) + var requestOptions = { + method: 'POST', + body: graphql, + }; + let post = (await (await fetch("http://localhost:1234/API/graphql.php", requestOptions)).json()).data.blogPost; content.innerHTML = post["content"]; document.title = post["title"] + " - Jonas Leder";