From 36b190e80e84a4c6fb30aef6858f8cb02a4ebe8b Mon Sep 17 00:00:00 2001 From: mphung1 Date: Wed, 21 Jun 2023 22:01:02 -0700 Subject: [PATCH] fix, add appsync key --- App.tsx | 2 ++ src/mainScreens/Home.tsx | 50 +++++++++++----------------------------- 2 files changed, 16 insertions(+), 36 deletions(-) diff --git a/App.tsx b/App.tsx index 18d01da..23f0227 100644 --- a/App.tsx +++ b/App.tsx @@ -45,6 +45,7 @@ const authLink = setContext(async (_, { headers }) => { headers: { ...headers, authorization: accessToken ? `Bearer ${accessToken}` : "", + "X-API-KEY": awsconfig.aws_appsync_apiKey, }, }; } catch (error) { @@ -52,6 +53,7 @@ const authLink = setContext(async (_, { headers }) => { return { headers: { ...headers, + "X-API-KEY": awsconfig.aws_appsync_apiKey, }, }; } diff --git a/src/mainScreens/Home.tsx b/src/mainScreens/Home.tsx index 7b6206d..0666b9a 100644 --- a/src/mainScreens/Home.tsx +++ b/src/mainScreens/Home.tsx @@ -35,7 +35,8 @@ const GET_VOUCHERS_INFO = gql` export default function VoucherScreen() { const { data, loading, error } = useQuery(GET_VOUCHERS_INFO); - console.log(data); + const { items } = data.listVouchers; + console.log(items); if (loading) { return ( @@ -61,43 +62,20 @@ export default function VoucherScreen() { console.log("swipe right"); }; - // useEffect(() => { - // async function getVoucherData() { - // await fetch(config.aws_appsync_graphqlEndpoint) - // .then((response) => { - // // Handle successful response - // console.log(response.data); - // }) - // .catch((error) => { - // // Handle error - // console.log(error); - // }); - // } - // getVoucherData(); - // }, []); - - // const ADD_VOUCHER = gql` - // mutation MyMutation { - // createVoucher( - // input: { - // numRedeemed: 10 - // priceBefore: 40 - // priceAfter: 35 - // forQuantity: 10 - // rating: 44 - // title: "Dining for 2" - // description: "There's nothing better" - // } - // ) { - // id - // } - // } - // `; - - // const [addVoucher] = useMutation(ADD_VOUCHER); - return ( + {/* {items.map((voucher) => ( + + {voucher.title} + {voucher.description} + Price Before: {voucher.priceBefore} + Price After: {voucher.priceAfter} + Created At: {voucher.createdAt} + Number Redeemed: {voucher.numRedeemed} + For Quantity: {voucher.forQuantity} + Rating: {voucher.rating} + + ))} */}