Skip to content
Snippets Groups Projects
Verified Commit 7e371dac authored by Jonas Leder's avatar Jonas Leder
Browse files

load blog posts from graphql

parent bd9be3b0
No related branches found
No related tags found
Loading
...@@ -26,7 +26,15 @@ async function loadPost() { ...@@ -26,7 +26,15 @@ async function loadPost() {
if(id == null) { if(id == null) {
content.innerHTML = "<h1>404 - Post not found</h1>"; content.innerHTML = "<h1>404 - Post not found</h1>";
} else { } 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"]; content.innerHTML = post["content"];
document.title = post["title"] + " - Jonas Leder"; document.title = post["title"] + " - Jonas Leder";
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment