0

I am trying to fetch data from hygraph by this way

    export const getCategories = async () => {
    const { categories } = await hygraph.request(
        `
          query GetGategories {
            categories {
                name
                coverImg {
                    url
                }
                posts {
                    titile
                    slug
                    coverPhoto {
                        url
                    }
                }
              }
          }
        `

    )
    return categories
}

and i call this function from a component using useEffect hook by this way

    useEffect(() => {
    getCategories().then((result) => {
        setRelatedPosts(result);
    });
}, []);

but this is showing error this error

enter image description here

i guess we dont call api from a component or is there any bug in my code?

Drew Reese
  • 165,259
  • 14
  • 153
  • 181
Sujjeee
  • 15
  • 4
  • A basic Google search yields, "What is error code 405 in GraphQL? The HyperText Transfer Protocol (HTTP) 405 Method Not Allowed response status code indicates that the server knows the request method, but the target resource doesn't support this method." Seems to be an issue with the server configuration. I'm guessing something with the CMS system. – Drew Reese Jan 14 '23 at 23:22

0 Answers0