.env
WP_GRAPHQL_URL = 'http://astro-wordpress.local/graphql'
pages/index.astro
---
const response = await fetch(`${import.meta.env.WP_GRAPHQL_URL}`, {
method: "POST",
headers: {
"Content-Type": "application/json",
},
body: JSON.stringify({
query: `
query PageQuery {
nodeByUri(uri: "/") {
... on Page {
id
blocks
}
}
}
`
})
});
const {data} = await response.json();
console.log(data.nodeByUri);
---
WPGraphiQL IDE
query NewQuery {
nodeByUri(uri: "/") {
... on Page {
id
blocks
}
}
}