I am facing an issue where I have an id called "test" as a parameter and I pass it to the index.js store. The error I see in the console is users?id=[object%20Object]. I tried converting the id with this.id.toString()
, but unfortunately, it did not resolve the problem. Can someone please assist me?
In my user.vue file:
<script>
import { mapActions } from "vuex";
export default {
data: () => ({
id: "test",
}),
methods: {
...mapActions("Test", [
"GET_USER_BY_ID",
]),
add() {
this.GET_USER_BY_ID(this.id);
},
},
};
</script>
And in my index.js file:
import axios from '../../plugins/axios'
const actions = {
GET_USER_BY_ID(userId) {
console.log(userId)
return axios.get(`users?id=${userId}`)
.then((response) => {
console.log(response)
return response
})
}
export default {
namespaced: true,
state,
getters,
actions,
mutations
}