From fabf06b8a6a53a39e7812fcc5eb4f47f634e33cf Mon Sep 17 00:00:00 2001 From: Asara Date: Sat, 22 Jun 2019 18:08:02 -0400 Subject: [PATCH] I have no idea what i'm doing :( --- src/actions/index.js | 6 +++--- src/components/NavBar.js | 6 ++++-- src/components/Post.js | 2 +- src/reducers/postsReducer.js | 2 ++ 4 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index d5902aa..902ccd4 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -5,7 +5,7 @@ export const fetchPosts = () => async (dispatch) => { dispatch({ type: 'FETCH_POSTS', payload: response.data }) }; -export const fetchPost = () => async (dispatch) => { - const response = await sudoscientist.get('/blog'); - dispatch({ type: 'FETCH_POSTS', payload: response.data }) +export const fetchPost = (id) => async (dispatch) => { + const response = await sudoscientist.get('/blog/' + id); + dispatch({ type: 'FETCH_POST', payload: response.data }) }; diff --git a/src/components/NavBar.js b/src/components/NavBar.js index c72fd0c..8ad3f0b 100644 --- a/src/components/NavBar.js +++ b/src/components/NavBar.js @@ -6,10 +6,12 @@ import PostList from './PostList'; class NavBar extends Component { render() { return ( -
- Home +
+ + Home Users Posts + About
); } diff --git a/src/components/Post.js b/src/components/Post.js index b6b6e7f..b195b9a 100644 --- a/src/components/Post.js +++ b/src/components/Post.js @@ -1,7 +1,7 @@ import React from 'react'; import ReactMarkdown from 'react-markdown'; import { connect } from 'react-redux'; -import { fetchPosts } from '../actions'; +import { fetchPost } from '../actions'; class Post extends React.Component { componentDidMount() { diff --git a/src/reducers/postsReducer.js b/src/reducers/postsReducer.js index 32daf04..e15f4be 100644 --- a/src/reducers/postsReducer.js +++ b/src/reducers/postsReducer.js @@ -2,6 +2,8 @@ export default (state = [], action) => { switch (action.type) { case 'FETCH_POSTS': return action.payload; + case 'FETCH_POST': + return action.payload; default: return state; }