Last active
January 21, 2019 15:34
-
-
Save funador/3f07d410095e5f425e0bd117aafe2011 to your computer and use it in GitHub Desktop.
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
const api = (() => { | |
const url = `${window.location.origin}/api` | |
const addTodo = todo => | |
axios.post(url, todo) | |
.then(res => res.data) | |
const deleteTodo = id => | |
axios.delete(`${url}/${id}`) | |
.then(res => res.data) | |
const updateTodo = (update, id) => | |
axios.put(`${url}/${id}`, update) | |
.then(res => res.data) | |
const getTodos = () => | |
axios.get(url) | |
.then(res => res.data) | |
return { | |
addTodo, | |
deleteTodo, | |
updateTodo, | |
getTodos | |
} | |
})() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment