Skip to content

Commit

Permalink
Merge pull request #7 from ptct-secret-recipes-3/valeriy-lysenko
Browse files Browse the repository at this point in the history
built HomePage component
  • Loading branch information
Valeriusdev authored Jul 30, 2021
2 parents 509b45a + 4bc7811 commit e459566
Showing 1 changed file with 33 additions and 6 deletions.
39 changes: 33 additions & 6 deletions src/components/HomePage.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React, { useState, useEffect } from "react";
import { axiosWithAuth } from "./axiosWithAuth";
import { Link } from "react-router-dom";

const HomePage = () => {

Expand All @@ -8,25 +9,51 @@ const HomePage = () => {
useEffect(() => {
const getRecipes = () => {
axiosWithAuth()
.get("#")
.get("api/recipes")
.then((res) => {
setRecipe(res.data);
})
.catch((err) => {
console.error({err});
});
};
getDatData();
getRecipes();
}, []);



return (
<div>
<section>
<div>
{recipe.map((res) => (
<Link to={`/recipe/${res.id}`} key={res.id}>
<section className="recipeCard">
<h2>{res.title}</h2>
<div>
<p>Source: </p> {res.source}
</div>
<div>
<p>Ingredients: </p> {res.ingredients}
</div>
<div>
<p>Instructions: </p> {res.instructions}
</div>
<div>
<p>Category: </p> {res.category}
</div>
</section>
</Link>
))}
</div>

<div>
<Link to="/RecipeForm">
<button> Create New Recipe </button>
</Link>
</div>

<h1>Our Recipes</h1>

</div>

</section>
);
};

Expand Down

1 comment on commit e459566

@vercel
Copy link

@vercel vercel bot commented on e459566 Aug 2, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.