Hey there!
I’m building a nextJS app and wanted to use Apollo to fetch some data. But unfortunately it doesn’t work as expected. The output is always the same : “typeError” - result is not iterable.
In the backend, the data comes in. So in the terminal all the data is logged. But on the frontend I get this error (image attached).
In my “apolloClient.js” i use this code:
import { ApolloClient, InMemoryCache } from '@apollo/client'
const client = new ApolloClient({
uri: 'https://eu-central-1-shared-euc1-02.cdn.hygraph.com/.../master',
cache: new InMemoryCache(),
})
export default client
and at the place where I want to fetch the data, I use the following:
Exactly. As soon as I try to fetch the data with Apollo this error occurred.
When I use dummy data like this https://jsonplaceholder.typicode.com/ it work‘s just fine…
First I thought it‘s because I have an error in the gql query. But I’m Hygraph, the query works and on the backend all the data is also logged in the terminal
Thanks @iamsebastn - I’m noticing a difference that might be relevant here.
In the first snippet you provided, the return value of generateStaticParams was:
That’s an object with one key slug, the value for which is an array of objects. Whereas in the working example, the return value is just an array of objects:
With the caveat that I don’t know much about Next.js, I’ll speculate that if you modify the first snippet to be an array of objects rather than nesting that array inside a POJO, you should see that error disappear. Hopefully that helps!