Created
February 25, 2020 06:27
-
-
Save rcoproc/ce93f7b8edb0211266beb0f391311832 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
import axios from 'axios'; | |
export function listTasks() { | |
return axios.get('/tasks.json') | |
.then(function(response){ | |
return response.data; | |
}) | |
} | |
export function createTask(task) { | |
var localTask = task; | |
delete localTask.id; | |
return axios.post('/tasks.json', localTask) | |
.then(function(response){ | |
return response.data; | |
}) | |
.catch(function(error){ | |
console.log(error); | |
}) | |
} | |
export function updateTask(task) { | |
var taskId = task.id; | |
var localTask = { name: task.name, | |
description: task.description, | |
completed: task.completed }; | |
return axios.put(`/tasks/${task.id}.json`, localTask) | |
.then(function(response){ | |
return response.data; | |
}) | |
.catch(function(error){ | |
console.log(error); | |
}) | |
} | |
export function deleteTask(task_id) { | |
return axios.delete(`/tasks/${task_id}.json`) | |
.then(function(response){ | |
return 'success'; | |
}) | |
.catch(function(error){ | |
console.log(error); | |
}) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment