How to fetch a single article from a publication

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
        post(slug: "the-developers-guide-to-chainlink-vrf-foundry-edition") {
            id
            title
            content {
                markdown
                html
            }
        }
    }
}

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

const query = `
  query Publication {
    publication(host: "blog.developerdao.com") {
      id
      isTeam
      title
      post(slug: "the-developers-guide-to-chainlink-vrf-foundry-edition") {
        id
        title
        content {
          markdown
          html
        }
      }
    }
  }
`;

fetch('https://gql.hashnode.com/', {
  method: 'POST',
  headers: {
    'Content-Type': 'application/json',
  },
  body: JSON.stringify({
    query: query,
  })
})
.then(response => response.json())
.then(data => {
  console.log('Article Title:', data.data.publication.post.title);
  console.log('Content (Markdown):', data.data.publication.post.content.markdown);
  console.log('Content (HTML):', data.data.publication.post.content.html);
})
.catch(error => console.error('Error fetching article:', error));
Updated on