I'm trying to fetch the data through Apollo Client in react native, the data is not getting fetched and giving errors, what should I do ? #1131
Unanswered
shubhamk-27
asked this question in
Q&A
Replies: 1 comment 2 replies
-
What errors? Please provide specifics. |
Beta Was this translation helpful? Give feedback.
2 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
import React from 'react';
import {Text, View, FlatList} from 'react-native';
import MI from 'react-native-vector-icons/MaterialIcons';
import {
ApolloProvider,
ApolloClient,
InMemoryCache,
useQuery,
gql,
} from '@apollo/client';
const GET_ALL_PRODUCTS = gql
{ products { items { name } } }
;const HomeScreen = props => {
const data = useQuery(GET_ALL_PRODUCTS);
JSON.parse(data);
return (
<MI name="menu" size={30} onPress={() => props.navigation.openDrawer()} />
Items
<View
style={{
display: 'flex',
flex: 1,
alignItems: 'center',
justifyContent: 'center',
}}>
<FlatList
data={data.products}
renderItem={({item}) => {item.name}}
/>
);
};
export default HomeScreen;
Beta Was this translation helpful? Give feedback.
All reactions