How to make a query in Apollo Client properly?

How to make a query in Apollo Client properly?


0

I’m new to Apollo Client and I want to test API endpoint to fetch the data.

 const client = new ApolloClient({
    cache: new InMemoryCache(),
    link: new HttpLink({
      uri: "https://api.thecatapi.com/v1/breeds",
      useGETForQueries: true
    }),
});

client
  .query({
    query: gql`
    {
        id
        name
    }
    `,
  })
  .then((result) => console.log(result))

In data field I keep getting undefined. I know that the problem is somewhere in the query but I can’t figure out how I should structure it.

Share
Improve this question


Load 4 more related questions


Show fewer related questions

0

Reset to default



Leave a Reply

Your email address will not be published. Required fields are marked *