Skip to content

Instantly share code, notes, and snippets.

@aramkoukia
Last active December 28, 2017 21:34
Show Gist options
  • Save aramkoukia/7b29f90190f94cbbeefcd7b86840ba83 to your computer and use it in GitHub Desktop.
Save aramkoukia/7b29f90190f94cbbeefcd7b86840ba83 to your computer and use it in GitHub Desktop.
MEVT TODO service
import axios from 'axios';
import { Todo } from './todo';
const api = 'api';
class TodoService {
deleteTodo(todo: Todo) {
return axios.delete(`${api}/todo/${todo.id}`);
}
getTodoes() {
return axios.get<Todo[]>(`${api}/todoes`);
}
addTodo(todo: Todo) {
return axios.post(`${api}/todo/`, { todo });
}
updateTodo(todo: Todo) {
return axios.put(`${api}/todo/${todo.id}`, { todo });
}
}
// Export a singleton instance in the global namespace
export const todoService = new TodoService();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment