'how to fetch data in apollo cilent

I have a problem fetching data with apollo client in reactJS, I can fetch this area but I can't reach the item and receive an error

console output : {getProducts: Array(3)}

Code For accessing items:

data.getProducts.map(iteam => console.log(iteam));

Error received :

TypeError: Cannot read properties of undefined (reading 'getProducts')


Solution 1:[1]

Solution :

Check Data Load Complete before Access data

 if (!loading && !error) {//Access Here}

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 vahid poormohamd