diff --git a/Frontend/src/pages/UserPanel/Farm/FarmPage.jsx b/Frontend/src/pages/UserPanel/Farm/FarmPage.jsx new file mode 100644 index 0000000..2a3a482 --- /dev/null +++ b/Frontend/src/pages/UserPanel/Farm/FarmPage.jsx @@ -0,0 +1,76 @@ +import React, { useEffect, useState } from "react"; +import { useParams } from "react-router-dom"; + +export default function FarmPage() { + const { farmId } = useParams(); + const [farmData, setFarmData] = useState({}); + + useEffect(() => { + async function fetching() { + try { + const response = await fetch( + `http://localhost:8000/api/v1/farm/${farmId}`, + { + method: "GET", + credentials: "include", + headers: { + "Content-Type": "application/json", + }, + } + ); + const jsonData = await response.json(); // renamed variable to avoid confusion + console.log(jsonData); + setFarmData(jsonData); + } catch (error) { + console.error("Error fetching farm data: ", error); + } + } + fetching(); + }, [farmId]); + + return ( +