Add comments as a child of the post
This commit is contained in:
parent
e182a5e920
commit
25e536bf7e
1 changed files with 2 additions and 1 deletions
|
@ -9,7 +9,8 @@ export const fetchPosts = () => async (dispatch) => {
|
||||||
export const fetchPost = (slug) => async (dispatch) => {
|
export const fetchPost = (slug) => async (dispatch) => {
|
||||||
const post = await sudoscientist.get('/blog/posts/by-slug/' + slug)
|
const post = await sudoscientist.get('/blog/posts/by-slug/' + slug)
|
||||||
const comments = await sudoscientist.get('/blog/comments/' + post.data.id);
|
const comments = await sudoscientist.get('/blog/comments/' + post.data.id);
|
||||||
const response = { post: post.data, comments: comments.data }
|
const response = { post: post.data }
|
||||||
|
response.post.comments = comments.data
|
||||||
dispatch({ type: 'FETCH_POST', payload: response })
|
dispatch({ type: 'FETCH_POST', payload: response })
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
Reference in a new issue