Fetch kész

This commit is contained in:
Kovács Rudolf committed 2026-11-05 09:48:29 +01:00
1 parent 237750bfef
commit 18bccaebe9
2 files changed
+13 -3

No files matched your search

+1 -1
View File
@@ -2,7 +2,7 @@
function Coffee({ coffee }) {
return (
<div className="card w-96 bg-blue-200 card-md shadow-sm">
<div className="card w-96 bg-blue-200 card-md shadow-sm m-2">
<div className="card-body">
<h2 className="card-title">{coffee.name}</h2>
<p>Roast:{coffee.roast}</p>
+12 -2
View File
@@ -5,7 +5,10 @@ function Coffees() {
const[coffees,setCoffees]=useState([]);
const getCoffees=()=>{
fetch('http://localhost:3000/coffees')
.then(res=>res.json())
.then(adat=>setCoffees(adat))
.catch(err=>alert(err));
}
useEffect(()=>{
@@ -13,7 +16,14 @@ function Coffees() {
},[]);
return (
<div>Coffees</div>
<div>
<h2 className="text-3xl text-center font-bold text-blue-800">Kávéink</h2>
<div className="flex flex-row flex-wrap items-center justify-center">
{
coffees.map((coffee)=>(<Coffee key={coffee.id} coffee={coffee} />))
}
</div>
</div>
)
}