From ac3c1b20609efcadee27d822f451c2c1de8a393f Mon Sep 17 00:00:00 2001 From: Camerin Figueroa Date: Mon, 25 Oct 2021 17:44:28 -0400 Subject: [PATCH] Started to create articles reducer and api --- public/articles.json | 9 +++++++++ src/reducers/articleReducer.js | 12 ++++++++++++ 2 files changed, 21 insertions(+) create mode 100644 public/articles.json create mode 100644 src/reducers/articleReducer.js diff --git a/public/articles.json b/public/articles.json new file mode 100644 index 0000000..f5647c7 --- /dev/null +++ b/public/articles.json @@ -0,0 +1,9 @@ +{ + "articles": [ + { + "title": "Test Article", + "desc":"This is a description", + "contents": "Hello World" + } + ] +} \ No newline at end of file diff --git a/src/reducers/articleReducer.js b/src/reducers/articleReducer.js new file mode 100644 index 0000000..989b804 --- /dev/null +++ b/src/reducers/articleReducer.js @@ -0,0 +1,12 @@ +let articleReducer = (state={articles=[]}, action) => { + switch(action.type) { + case "GET_ARTICLES": + return { ...state, articles: action.payload }; + + default: + return state; + } + }; + + +export default articleReducer; \ No newline at end of file