[Vuejs]-Hashnode API with GraphQL API resulting in error

0👍

I think you should try using fetch. I’ve had a tough one with axios when using it in node and I was finally able to get the api to work with fetch. Here is a snippet of what worked for me.

const getData = async() => {
const query = `
        {
        user(username: "misiochaabel") {
            publication {
                posts(page: 0) {
                    slug
                    title
                    brief
                    coverImage
                }
            }
            }
        }
    `;

        const response = await fetch('https://api.hashnode.com/', {
            method: 'POST',
            headers: {
                'Content-Type': 'application/json',
            },
            body: JSON.stringify({ query }),
        });

        const data = await response.json();
        console.log(data);
    }

Leave a comment