Working on chap03
parent
14c4682dcf
commit
9261ffe063
|
@ -19,6 +19,18 @@ export const fetchPosts = createAsyncThunk('posts/fetchPosts', async () => {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
export const addNewPost = createAsyncThunk(
|
||||||
|
'posts/addNewPost',
|
||||||
|
async (initialPost) => {
|
||||||
|
try {
|
||||||
|
const response = await axios.post(POSTS_URL, initialPost);
|
||||||
|
return response.data;
|
||||||
|
} catch (err) {
|
||||||
|
return err.message;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
const postsSlice = createSlice({
|
const postsSlice = createSlice({
|
||||||
name: 'posts',
|
name: 'posts',
|
||||||
initialState,
|
initialState,
|
||||||
|
|
Loading…
Reference in New Issue