1
0
Fork 0

Add comments as a child of the post

This commit is contained in:
Amarpreet Minhas 2020-01-29 20:39:48 -05:00
parent e182a5e920
commit 25e536bf7e

View file

@ -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 })
}; };