Fix up path to blog posts
This commit is contained in:
parent
58a8fa234a
commit
38bd1ebfd6
2 changed files with 7 additions and 5 deletions
|
@ -2,18 +2,19 @@ import sudoscientist from '../apis/sudoscientist';
|
||||||
import history from './history'
|
import history from './history'
|
||||||
|
|
||||||
export const fetchPosts = () => async (dispatch) => {
|
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 })
|
dispatch({ type: 'FETCH_POSTS', payload: response.data })
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchPost = (slug) => async (dispatch) => {
|
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 })
|
dispatch({ type: 'FETCH_POST', payload: response.data })
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
export const fetchUserProfile = (user) => async (dispatch) => {
|
export const fetchUserProfile = (user) => async (dispatch) => {
|
||||||
const profile = await sudoscientist.get('/users/' + user);
|
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 test = {posts: userPosts.data}
|
||||||
const response = { ...profile.data, ...test }
|
const response = { ...profile.data, ...test }
|
||||||
dispatch({ type: 'FETCH_USER', payload: response })
|
dispatch({ type: 'FETCH_USER', payload: response })
|
||||||
|
@ -55,7 +56,7 @@ export const loadCookieToState = (data) => async (dispatch) => {
|
||||||
|
|
||||||
|
|
||||||
export const newBlogPost = (payload) => 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) {
|
if (response.status === 201) {
|
||||||
history.push('/posts/' + response.data.slug)
|
history.push('/posts/' + response.data.slug)
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,8 @@ class Post extends React.Component {
|
||||||
const mapStateToProps = (state) => {
|
const mapStateToProps = (state) => {
|
||||||
return {
|
return {
|
||||||
posts: state.posts,
|
posts: state.posts,
|
||||||
slug: state.slug
|
slug: state.slug,
|
||||||
|
comments: state.comments
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Reference in a new issue