How to transfer multiple parameters in Vuex action

5 days ago 6
ARTICLE AD BOX

I know that you can put multiple parameters in one object, and that's what I'm trying to do - I tried to implement it, but apparently I'm missing the basics, because the second parameter is always undefined.

Can you tell me how to fix the problem and what I'm missing in this situation?

in <script> of component:

methods: { ...mapActions({ deleteComment: 'comment/deleteComment' }), removeComment() { const comment = this.comment const article = this.article const payload = { article:article, comment:comment } this.deleteComment(payload) } }

in Vuex module:

//action async deleteComment({state, commit}, payload) { try { console.log('payload') const aid = payload.acticle.id const cid = payload.comment.id const response = await axios.delete(`http://localhost:5000/article/${aid}/comment/${cid}`) } catch(e) { alert('Error', e) } }

When I try to console.log(payload) it shows normal parameter

image of console.log

Am I take value of params in right way?

I seem to understand what the problem is, but changing the parameter transmission and trying to follow tips from the Internet and examples from the documentation, I don't understand simple things. I will be glad of any help.

Read Entire Article