Im trying to build my own like system with Laravel, VUE, & Vuetify, but I ran into a problem. In order for the likes to increment +1 in the database, 2 quick clicks are required. If I use a normal slow click, the likes amount will just revert back to the original amount.
In my methods I have the following
addLike(like, id) {
axios.put('/api/posts/' + id, {
likes: like++
})
.then(res => {
this.$toast.success('You liked a post')
this.$store.dispatch('post/fetchPosts')
this.$emit('success', res.data)
})
},
The button used to click the method
<v-btn
@click.stop="addLike(post.likes++, post.id)"
icon
class="mx-auto"
><v-icon>mdi-heart</v-icon>{{ post.likes }}
</v-btn>