Vue.js Passing Button Parameters to Veux Store
Solution 1:
If I'm understanding correctly you want to have a POST api call that can be used by any of your vue.js components.
This could be best acheived by using a Vuex action, and then mapping that action using mapActions
in your vuex file:
...
actions: {
async postData({state}, data) {
const result = await axios.post('//your/endpoint', data);
return result
}
}
In your vue component:
<template>
<div>
<button @click="postData('data to post')">Post</button>
</div>
</template>
<script>
import { mapActions } from 'vuex'
export default {
methods: {
...mapActions(['postData'])
}
}
</script>