November 2017
Beginner to intermediate
398 pages
8h 42m
English
Before going into functional components, we need to lay the groundwork in the Vue
addComment (state, { post, comment }) { post.comments.push(comment) },
async sendComment({ commit, rootGetters }, { post, comment }) { const user = rootGetters.user commit('addComment', { post, comment: { ...comment, date: new Date(), user_id: user._id, author: user, }, }) await $fetch(`posts/${post._id}/comment`, { method: 'POST',
body: JSON.stringify(comment), }) },
Read now
Unlock full access