Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 12 additions & 9 deletions frontend/src/components/data.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,10 @@ import { useEffect } from "react";
const Data = () => {
const [data, setData] = useState([]);
const [error, setError] = useState("");
try {
useEffect(() => {
const fetchData = async () => {

useEffect(() => {
const fetchData = async () => {
try {
const rawData = await fetch("http://127.0.0.1:5000/posts")
.then((data) => data.json())
.then((response) => {
Expand All @@ -17,12 +18,14 @@ const Data = () => {
console.error("There was an error!", error.message);
setError(error.message);
});
};
fetchData();
}, []);
} catch (ex) {
console.log(ex);
}
} catch (ex) {
console.log(ex);
}
};

fetchData();
}, []);

const table = (
<>
<p>Data Successfully retrieved!</p>
Expand Down