0

I have been using vuex for a project for a few days now. Now I need to pass the value of a state to the created method. Below I show the code used.

Store file

state: {
     friendstatus: null 

},
mutations: {
SET_FRIEND_STATUS: (state,friend) => {
  state.friendstatus = data;
},
actions: {
getFriendStatus: ({commit},data) => {
  //axios request returns friendstatus
commit('STATE_FRIEND_STATUS',response.data.status)
}

Vue component

computed: {
...mapstate('friend',['friendstatus'])
},
created() {
//Here I need to pass friendstatus. Obviously if I call this.friendstatus it does not work. 
 this.$store.dispatch('friend/getFriendStatus);// I would like to call the state and not the action 
}

0 Answers0