Skip to content

Commit

Permalink
fix, add appsync key
Browse files Browse the repository at this point in the history
  • Loading branch information
mphung1 committed Jun 22, 2023
1 parent 405f1b0 commit 36b190e
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 36 deletions.
2 changes: 2 additions & 0 deletions App.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,15 @@ const authLink = setContext(async (_, { headers }) => {
headers: {
...headers,
authorization: accessToken ? `Bearer ${accessToken}` : "",
"X-API-KEY": awsconfig.aws_appsync_apiKey,
},
};
} catch (error) {
console.log("Error fetching tokens:", error);
return {
headers: {
...headers,
"X-API-KEY": awsconfig.aws_appsync_apiKey,
},
};
}
Expand Down
50 changes: 14 additions & 36 deletions src/mainScreens/Home.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
Expand All @@ -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 (
<View style={nStyles.container}>
{/* {items.map((voucher) => (
<View key={voucher.id}>
<Text>{voucher.title}</Text>
<Text>{voucher.description}</Text>
<Text>Price Before: {voucher.priceBefore}</Text>
<Text>Price After: {voucher.priceAfter}</Text>
<Text>Created At: {voucher.createdAt}</Text>
<Text>Number Redeemed: {voucher.numRedeemed}</Text>
<Text>For Quantity: {voucher.forQuantity}</Text>
<Text>Rating: {voucher.rating}</Text>
</View>
))} */}
<CustomHeaderBar />
<VoucherStack
data={vouchers}
Expand Down

0 comments on commit 36b190e

Please sign in to comment.