Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @VuexAction
- async addCommentAPI (commentData: any) {
- axios.post('http://127.0.0.1:8000/api/comments/', {
- author_pk: this.context.rootState.modules.User.loggedUserData.id,
- content: commentData.content,
- to_post: `http://127.0.0.1:8000/api/posts/${commentData.postId}/`
- })
- .then((res) => {
- this.context.commit('storeComment', res.data)
- })
- .catch((err) => {
- if (err.response.status === 401) {
- this.context.dispatch(
- 'Root/refreshTokenAndRepeatAction',
- 'Root/modules/Posts/addCommentAPI',
- { root: true }
- )
- }
- })
- }
Advertisement
Add Comment
Please, Sign In to add comment