From ae11651e42cb01a8ab38124e06549862897fe7ab Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?Chif=20Gerg=C5=91?= <chifgeri97@gmail.com>
Date: Sat, 29 Dec 2018 19:52:44 +0100
Subject: [PATCH] Create actions to get events from backend

---
 src/actions/statistics.js | 16 ++++++++++++++++
 src/actions/types.js      |  2 ++
 2 files changed, 18 insertions(+)
 create mode 100644 src/actions/statistics.js

diff --git a/src/actions/statistics.js b/src/actions/statistics.js
new file mode 100644
index 0000000..f4d9d8e
--- /dev/null
+++ b/src/actions/statistics.js
@@ -0,0 +1,16 @@
+import { axios } from './auth';
+import { GET_EVENTS } from './types';
+
+export const getEvents = () => (
+  async (dispatch) => {
+    try {
+      const response = await axios.get('/api/v1/events');
+      dispatch({
+        type: GET_EVENTS,
+        payload: response.data,
+      });
+    } catch (e) {
+      console.log(e);
+    }
+  }
+);
diff --git a/src/actions/types.js b/src/actions/types.js
index 177bbd7..5d96253 100644
--- a/src/actions/types.js
+++ b/src/actions/types.js
@@ -10,3 +10,5 @@ export const ADD_NEWS = 'add_news';
 export const DELETE_NEWS = 'delete_news';
 export const EDIT_NEWS = 'edit_news';
 export const SELECT_NEWS = 'select_news';
+
+export const GET_EVENTS = 'get_events';
-- 
GitLab