0
votes

How to fix it?

computed: {
  ...mapGetters({
    eleron: 'promoter/eleron',
  }),
},

GetInfo (call when press search button):

getInfo() {
    this.loading = true;
    axios.post('/srt', {
      search: this.search
    })
    .then((response) => {this.eleron = response.data, console.log(response.data), this.loading = false;});
},
2

2 Answers

0
votes

You are mapping the getters from vuex. This means that you can only get the value from the store, you cannot write to it.

You need to also map a mutation.

Something like this should work, depending on the fact that you have a mutation defined on the store:

methods: {
 ...mapMutations([
  'updateEleron'
 ]),
}

And then call it in the promise callback

this.updateEleron(response.data)

Note: vuex offers read only access to variables from outside the store. Writing to a variable needs to be done from inside a mutation or action.

-1
votes

New error Radu: ReferenceError: mapMutations is not defined

methods:{
        ...mapActions({
            getPromoters: 'promoter/getEleron',
            removePromoter: 'promoter/removeEleron'
        }),
        ...mapMutations([
          'updateEleron'
         ]),
        getInfo()
        {
            this.loading = true;
            axios.post('/srt', {
                search: this.search
            })
            .then((response) => {this.updateEleron(response.data), console.log(response.data), this.loading = false;});
        },
    },