David Prince
fix: add all missing local module stubs (remote_mcp_registry, mcp_auth, mcp_transport, etc)
cce8120
Raw
History Blame Contribute Delete
1.13 kB
import { Todo } from '../types';
const API_URL = '/todos';
export const fetchTodos = async (): Promise<Todo[]> => {
const res = await fetch(API_URL);
if (!res.ok) {
throw new Error('Failed to fetch todos');
}
return res.json();
};
export const createTodo = async (data: { title: string; completed?: boolean }): Promise<Todo> => {
const res = await fetch(API_URL, {
method: 'POST',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
});
if (!res.ok) {
throw new Error('Failed to create todo');
}
return res.json();
};
export const updateTodo = async (id: number, data: Partial<Todo>): Promise<Todo> => {
const res = await fetch(`${API_URL}/${id}`, {
method: 'PUT',
headers: { 'Content-Type': 'application/json' },
body: JSON.stringify(data),
});
if (!res.ok) {
throw new Error('Failed to update todo');
}
return res.json();
};
export const deleteTodo = async (id: number): Promise<void> => {
const res = await fetch(`${API_URL}/${id}`, {
method: 'DELETE',
});
if (!res.ok) {
throw new Error('Failed to delete todo');
}
};