Update actions to include getting comments
This commit is contained in:
parent
38bd1ebfd6
commit
1a5d37f116
1 changed files with 4 additions and 2 deletions
|
@ -7,8 +7,10 @@ export const fetchPosts = () => async (dispatch) => {
|
||||||
};
|
};
|
||||||
|
|
||||||
export const fetchPost = (slug) => async (dispatch) => {
|
export const fetchPost = (slug) => async (dispatch) => {
|
||||||
const response = await sudoscientist.get('/blog/posts/by-slug/' + slug);
|
const post = await sudoscientist.get('/blog/posts/by-slug/' + slug)
|
||||||
dispatch({ type: 'FETCH_POST', payload: response.data })
|
const comments = await sudoscientist.get('/blog/comments/' + post.data.id);
|
||||||
|
const response = { ...post.data, ...comments.data }
|
||||||
|
dispatch({ type: 'FETCH_POST', payload: response })
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
Reference in a new issue