aboutsummaryrefslogblamecommitdiff
path: root/src/api/axios_methods.js
blob: c68cc21a602716a761b0efb38a0caa49e05ae2ed (plain) (tree)
1
2
3
4
5
6
7
8
9
10


                                 
                                      
                                
                   
                               
             

                                                     




                             
















                                        
import api from "./axios_config";

// findAll() on Back End.
export function get_todos_function() {
    // Get a list of all to dos.
    // GET "/todos"
    return async (handler) => {
        try {
            const response = await api.get("/todos");
            handler(response.data);
        } catch (err) {
            console.log(err);
        }
    };
}

// addToDo() on Back End.
export function new_todo_function() {
    // Add a new to do on database.
    // POST "/todos"
    return async (data) => {
        try {
            await api.post("/todos", {
                text: data.text,
                dueDate: data.due_date,
                priority: data.priority,
            });
        } catch (err) {
            console.log(err);
        }
    };
}