Open History to see the last commit
1import type { Todo } from './types'
2β
3export const todosAPI = {
4 getTodos: (): Promise<Array<Todo>> => $fetch('/api/todos'),
5 createTodo: (text: string): Promise<Todo> =>
6 $fetch('/api/todos', { method: 'POST', body: { text } }).catch(
7 (error: { data?: { message?: string }; message: string }) => {
8 throw new Error(error.data?.message ?? error.message)
9 },
10 ),
11}