Last active
December 28, 2017 21:34
-
-
Save aramkoukia/7b29f90190f94cbbeefcd7b86840ba83 to your computer and use it in GitHub Desktop.
MEVT TODO service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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