()
| 25 | }) |
| 26 | |
| 27 | export async function fetchTodosFromServer(): Promise<TodosResponse> { |
| 28 | await delay(90) |
| 29 | if (failNextFetch) { |
| 30 | failNextFetch = false |
| 31 | throw new Error('Forced fetch failure (test)') |
| 32 | } |
| 33 | requestCount += 1 |
| 34 | |
| 35 | return { |
| 36 | items: todos.map((todo) => ({ ...todo })), |
| 37 | requestCount, |
| 38 | source: 'server', |
| 39 | } |
| 40 | } |
| 41 | |
| 42 | export async function addTodoOnServer(title: string): Promise<Todo> { |
| 43 | await delay(70) |