diff --git a/js/viewPost.js b/js/viewPost.js index 01241e908784e33d2907bf31be386a0f8cda6ecf..3c556349c4b568a179bfba32c3827c5bf405ed3b 100644 --- a/js/viewPost.js +++ b/js/viewPost.js @@ -26,7 +26,15 @@ async function loadPost() { if(id == null) { content.innerHTML = "<h1>404 - Post not found</h1>"; } 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";