| 32 | * Mock function that mimics fetching todos from a database. |
| 33 | */ |
| 34 | export const fetchTodos = async (query = ""): Promise<Todo[]> => { |
| 35 | await new Promise((resolve) => setTimeout(resolve, 1000)); |
| 36 | |
| 37 | console.log("fetched todos"); |
| 38 | |
| 39 | const filteredTodos = todos.filter((todo) => |
| 40 | todo.title.toLowerCase().includes(query.toLowerCase()) |
| 41 | ); |
| 42 | |
| 43 | // Uncomment the line below to trigger an error |
| 44 | // throw new Error(); |
| 45 | |
| 46 | return [...filteredTodos]; |
| 47 | }; |
| 48 | |
| 49 | /** |
| 50 | * Mock function that mimics adding a todo to a database. |