From 68b54eb47f70cfca04d8fe3d25edaf8a4545e405 Mon Sep 17 00:00:00 2001
From: donal <donalspring@gmail.com>
Date: Wed, 04 Apr 2018 17:12:39 +0200
Subject: [PATCH] ADDING delete functionality

---
 src/store/actions.js |   12 +++++++++++-
 1 files changed, 11 insertions(+), 1 deletions(-)

diff --git a/src/store/actions.js b/src/store/actions.js
index 844a6b8..8c7de9b 100644
--- a/src/store/actions.js
+++ b/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");
   }
 };

--
Gitblit v1.9.3