Working on chap03

03_lesson
jason-zhu 2023-10-22 00:33:57 +11:00
parent 14c4682dcf
commit 9261ffe063
1 changed files with 12 additions and 0 deletions

View File

@ -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({
name: 'posts',
initialState,