How to fetch posts from your blog

In this guide, you'll learn how to integrate the following GraphQL query into your applications using JavaScript, Python, Golang and Java:

 query Publication {
    publication(host: "blog.developerdao.com") {
        id
        isTeam
        title
        posts(first: 10) {
            edges {
                node {
                    id
                    title
                    brief
                    url
                }
            }
        }
    }
}

Run it on our API playground to see how it works.

const query = `
   query {
      publication(host: "blog.developerdao.com") {
        id
        isTeam
        title
        posts(first: 10) {
          edges {
            node {
              id
              title
              brief
              url
            }
          }
        }
      }
  }
`;

fetch('https://gql.hashnode.com', { 
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({ query })
})
.then(response => response.json())
.then(data => console.log(data))
.catch(error => console.error('Error:', error));
Updated on