donal
2018-04-04 68b54eb47f70cfca04d8fe3d25edaf8a4545e405
ADDING delete functionality
1 files modified
12 ■■■■■ changed files
src/store/actions.js 12 ●●●●● patch | view | raw | blame | history
src/store/actions.js
@@ -67,7 +67,17 @@
  clearAllTodos({ commit }) {
    commit("CLEAR_ALL_TODOS");
  },
  clearAllDoneTodos({ commit }) {
  clearAllDoneTodos({ commit, state }) {
    // 1 fire and forget or
    state.todos.map(todo => {
      // axios remove all done by the id
      if (todo.completed){
        axios.delete(config.todoEndpoint + '/' + todo._id).then(data => {
          console.info("INFO - item " + todo._id + " deleted", data);
        });
      }
    });
    //  2 return array of promises and resolve all
    commit("CLEAR_ALL_DONE_TODOS");
  }
};