diff --git a/client/src/components/Create-Recipe/AddRecipe.js b/client/src/components/Create-Recipe/AddRecipe.js index 057ede5..dd34b71 100644 --- a/client/src/components/Create-Recipe/AddRecipe.js +++ b/client/src/components/Create-Recipe/AddRecipe.js @@ -37,6 +37,8 @@ export const AddRecipe = () => { // .catch((err) => console.log(err)); // }, []); + + const addRecipe = (e) => { e.preventDefault(); axios.post('http://localhost:8000/api/addRecipe', { diff --git a/client/src/components/One-Recipe/RecipeCard.js b/client/src/components/One-Recipe/RecipeCard.js index 2fb9e15..a88c3e4 100644 --- a/client/src/components/One-Recipe/RecipeCard.js +++ b/client/src/components/One-Recipe/RecipeCard.js @@ -1,11 +1,32 @@ import Nav from '../Nav/Nav' import './RecipeCard.css' +import { useLocation } from 'react-router-dom' +import { useParams } from 'react-router-dom' +import { useState } from 'react' +import { useEffect } from 'react' +import axios from 'axios' const RecipeCard = (props) => { + let location = useLocation(); + const { id } = useParams(); + const [recipe, setRecipe] = useState({}); + + console.log("This is the location", location) + + useEffect(() => { + axios.get(`http://127.0.0.1:8000/api/recipe/${id}`) + .then(response => { + console.log(response.data) + setRecipe(response.data) + }) + .catch(error => { + console.log(error, 'nope') + }) + },[]) //We pull down the list of all recipes via props so that cards can be generated for each. - const {recipe} = props + // const {recipe} = props // Switching between image and directions view @@ -20,6 +41,7 @@ const RecipeCard = (props) => { } // We need to plug in recipe.title, recipe.serves , etc + // GJL Working on this now!!!! return (
Ingredients list goes here
- {/*{recipe.ingredients}
*/} +{recipe.ingredients}
{recipe.instructions}
*/} -directions
-directions
+{recipe.instructions}
+ {/*directions
directions
+directions
*/}{recipe.creator}