From 9f37cf6b5881444475bfae29f64f585b89dfb1cc Mon Sep 17 00:00:00 2001 From: dvirlabs <114520947+dvirlabs@users.noreply.github.com> Date: Thu, 3 Jul 2025 15:51:47 +0300 Subject: [PATCH] Update app to fetch correctly --- frontend/src/App.jsx | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/frontend/src/App.jsx b/frontend/src/App.jsx index 820d4da..ceaafb0 100644 --- a/frontend/src/App.jsx +++ b/frontend/src/App.jsx @@ -1,22 +1,17 @@ -// src/App.jsx import { useEffect, useState } from 'react'; import './App.css'; import SectionGrid from './components/SectionGrid'; import AddAppModal from './components/AddAppModal'; import Clock from './components/Clock'; - +import { fetchSections } from './services/api'; // ✅ שימוש בפונקציה הנכונה function App() { const [sections, setSections] = useState([]); - const fetchSections = () => { - fetch('/api/apps') - .then(res => res.json()) - .then(data => setSections(data.sections || [])); - }; - useEffect(() => { - fetchSections(); + fetchSections() + .then(data => setSections(data.sections || [])) + .catch(err => console.error('Failed to fetch sections:', err)); }, []); return ( @@ -34,4 +29,4 @@ function App() { ); } -export default App; \ No newline at end of file +export default App;