TypeError (...) is not a function

Hello there,

I have a problem with compiling a vue file. I got 2 errors for probably one underlying problem. The error-messages are the following:

- [Vue warn]: Error in callback for watcher "changeKundeStore": "TypeError: vm.kundeinputstore is not a function"

- TypeError: vm.kundeinputstore is not a function

The corresponding code is the following:

watch:{
        changeKundeStore: function() {
            let vm = this;
            vm.kundeUebertrag = vm.kundeInputStore();
            console.log(this.kundeUebertrag);
            
            $.getJSON("/api/get_bereich.php", {kundeUebertrag: this.kundeUebertrag } , function(result){
                console.log(result);
                vm.bereiche = result;
                
            });
        }
    }

I have already searched the forum, but did not found a solution. If this is a duplicate please post the link here.

Thanks in advance!

1 Like

I forgot to add this:

computed: {
        kundeInputStore: function() 
        {
            return this.$store.state.kundeInputStore
        },

        changeKundeStore: function()
        {
            return this.$store.state.changeKundeStore
        }
    },

Well, as the error states, kundeInputStore is not a function - but you call it like a function:

vm.kundeUebertrag = vm.kundeInputStore();

It is a computed property, so you should access it like a property:

vm.kundeUebertrag = vm.kundeInputStore;
1 Like

Yes, that erased the error warning.
Thanks!