Spaces:
Running
Running
| // Function to fetch todos from API | |
| import axios from 'axios'; | |
| export const fetchTodos = async () => { | |
| try { | |
| const res = await axios.get('/api/todos'); | |
| const data = await res.json(); | |
| return data; | |
| } catch (error) { | |
| console.error(error); | |
| return []; | |
| } | |
| }; |