File size: 275 Bytes
49715c3
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
// 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 [];
 }
};