diff --git a/README.md b/README.md index 824bb70..722bd0e 100644 --- a/README.md +++ b/README.md @@ -15,4 +15,7 @@ Payment information will be supported through the Stripe API, with session suppo ## Accessing the Project and its REST API Online 1. The REST API for this project is exposed at https://mikayla-spice-market-api.herokuapp.com/ -2. The client site will be hosted on Netlify and is not online as of yet. \ No newline at end of file +2. The client site will be hosted on Netlify and is not online as of yet. + +## Accessing API Documentation +The Swagger docs for this project can be accessed at https://mikayla-spice-market-api.herokuapp.com/api-docs/ \ No newline at end of file diff --git a/client/src/components/Product/AllProducts.tsx b/client/src/components/Product/AllProducts.tsx index 759dece..2ba272a 100644 --- a/client/src/components/Product/AllProducts.tsx +++ b/client/src/components/Product/AllProducts.tsx @@ -1,4 +1,19 @@ +import { useEffect, useState } from "react" +import { getAllProducts } from "../../util/apiUtils"; + export default function AllProducts() { + const [productData, setProductData] = useState(); + + useEffect(() => { + getAllProducts() + .then(res => res.json()) + .then(res => setProductData(res)); + }, []) + + useEffect(() => { + console.log(productData); + }, [productData]) + return (

All Products!

) diff --git a/client/src/util/apiUtils.ts b/client/src/util/apiUtils.ts new file mode 100644 index 0000000..649f588 --- /dev/null +++ b/client/src/util/apiUtils.ts @@ -0,0 +1,4 @@ +export const getAllProducts = async () => { + const response = await fetch("https://mikayla-spice-market-api.herokuapp.com/product"); + return response; +} \ No newline at end of file