Skip to content

Commit

Permalink
added index action creator
Browse files Browse the repository at this point in the history
  • Loading branch information
StephenGrider committed Apr 13, 2017
1 parent 3cf4a1b commit 66dfdaf
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
4 changes: 3 additions & 1 deletion blog/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,14 @@
"webpack-dev-server": "^1.14.0"
},
"dependencies": {
"axios": "^0.16.1",
"babel-preset-stage-1": "^6.1.18",
"lodash": "^3.10.1",
"react": "^0.14.3",
"react-dom": "^0.14.3",
"react-redux": "4.0.0",
"react-router-dom": "^4.0.0",
"redux": "^3.0.4"
"redux": "^3.0.4",
"redux-promise": "^0.5.3"
}
}
15 changes: 15 additions & 0 deletions blog/src/actions/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import axios from 'axios';

export const FETCH_POSTS = 'fetch_posts';

const ROOT_URL = 'http://reduxblog.herokuapp.com/api';
const API_KEY = '?key=PAPERCLIP1234';

export function fetchPosts() {
const request = axios.get(`${ROOT_URL}/posts${API_KEY}`);

return {
type: FETCH_POSTS,
payload: request
};
}
3 changes: 2 additions & 1 deletion blog/src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,12 @@ import ReactDOM from 'react-dom';
import { Provider } from 'react-redux';
import { createStore, applyMiddleware } from 'redux';
import { BrowserRouter, Route } from 'react-router-dom';
import promise from 'redux-promise';

import reducers from './reducers';
import PostsIndex from './components/posts_index';

const createStoreWithMiddleware = applyMiddleware()(createStore);
const createStoreWithMiddleware = applyMiddleware(promise)(createStore);

ReactDOM.render(
<Provider store={createStoreWithMiddleware(reducers)}>
Expand Down

0 comments on commit 66dfdaf

Please sign in to comment.