From 38bd1ebfd66da45df15c0371db6e53e337966ffd Mon Sep 17 00:00:00 2001 From: Asara Date: Sat, 25 Jan 2020 23:40:48 -0500 Subject: [PATCH] Fix up path to blog posts --- src/actions/index.js | 9 +++++---- src/components/Post.js | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/actions/index.js b/src/actions/index.js index 54f3775..d37274c 100644 --- a/src/actions/index.js +++ b/src/actions/index.js @@ -2,18 +2,19 @@ import sudoscientist from '../apis/sudoscientist'; import history from './history' export const fetchPosts = () => async (dispatch) => { - const response = await sudoscientist.get('/blog'); + const response = await sudoscientist.get('/blog/posts'); dispatch({ type: 'FETCH_POSTS', payload: response.data }) }; export const fetchPost = (slug) => async (dispatch) => { - const response = await sudoscientist.get('/blog/by-slug/' + slug); + const response = await sudoscientist.get('/blog/posts/by-slug/' + slug); dispatch({ type: 'FETCH_POST', payload: response.data }) }; + export const fetchUserProfile = (user) => async (dispatch) => { const profile = await sudoscientist.get('/users/' + user); - const userPosts = await sudoscientist.get('/blog/by-author/' + user); + const userPosts = await sudoscientist.get('/blog/posts/by-author/' + user); const test = {posts: userPosts.data} const response = { ...profile.data, ...test } dispatch({ type: 'FETCH_USER', payload: response }) @@ -55,7 +56,7 @@ export const loadCookieToState = (data) => async (dispatch) => { export const newBlogPost = (payload) => async (dispatch) => { - const response = await sudoscientist.post('/blog', payload) + const response = await sudoscientist.post('/blog/posts', payload) if (response.status === 201) { history.push('/posts/' + response.data.slug) } diff --git a/src/components/Post.js b/src/components/Post.js index a98d991..350fd85 100644 --- a/src/components/Post.js +++ b/src/components/Post.js @@ -47,7 +47,8 @@ class Post extends React.Component { const mapStateToProps = (state) => { return { posts: state.posts, - slug: state.slug + slug: state.slug, + comments: state.comments }; }