Guest User

Untitled

a guest
Feb 15th, 2021
72
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. @VuexAction
  2.   async addCommentAPI (commentData: any) {
  3.     axios.post('http://127.0.0.1:8000/api/comments/', {
  4.       author_pk: this.context.rootState.modules.User.loggedUserData.id,
  5.       content: commentData.content,
  6.       to_post: `http://127.0.0.1:8000/api/posts/${commentData.postId}/`
  7.     })
  8.       .then((res) => {
  9.         this.context.commit('storeComment', res.data)
  10.       })
  11.       .catch((err) => {
  12.         if (err.response.status === 401) {
  13.           this.context.dispatch(
  14.             'Root/refreshTokenAndRepeatAction',
  15.             'Root/modules/Posts/addCommentAPI',
  16.             { root: true }
  17.           )
  18.         }
  19.       })
  20.   }
Advertisement
Add Comment
Please, Sign In to add comment