Refactor code, split routes, change url in backend and update in frontend. Still have bugs, infinite loading after signup?

This commit is contained in:
estherdev03
2025-03-19 02:09:30 -06:00
parent 3ac9ed00a2
commit c75fa01392
14 changed files with 582 additions and 510 deletions

View File

@@ -10,7 +10,9 @@ const Home = () => {
useEffect(() => {
const fetchProducts = async () => {
try {
const response = await fetch("http://localhost:3030/get_product");
const response = await fetch(
"http://localhost:3030/api/product/get_product"
);
if (!response.ok) throw new Error("Failed to fetch products");
const data = await response.json();
@@ -27,7 +29,7 @@ const Home = () => {
seller: "Unknown", // Modify if seller info is available
datePosted: "Just now",
isFavorite: false,
})),
}))
);
} else {
throw new Error(data.message || "Error fetching products");
@@ -48,8 +50,8 @@ const Home = () => {
prevListings.map((listing) =>
listing.id === id
? { ...listing, isFavorite: !listing.isFavorite }
: listing,
),
: listing
)
);
};