1
0
Fork 0

Update actions to include getting comments

This commit is contained in:
Amarpreet Minhas 2020-01-26 00:13:20 -05:00
parent 38bd1ebfd6
commit 1a5d37f116

View file

@ -7,8 +7,10 @@ export const fetchPosts = () => async (dispatch) => {
};
export const fetchPost = (slug) => async (dispatch) => {
const response = await sudoscientist.get('/blog/posts/by-slug/' + slug);
dispatch({ type: 'FETCH_POST', payload: response.data })
const post = await sudoscientist.get('/blog/posts/by-slug/' + slug)
const comments = await sudoscientist.get('/blog/comments/' + post.data.id);
const response = { ...post.data, ...comments.data }
dispatch({ type: 'FETCH_POST', payload: response })
};