[Vuejs]-Vue.js props not showing actual message value, What have I done and how can I solve it?

2👍

Rewrite your created method, so you bind your own this:

created: function() {
    axios.get('/Chat/public/messages')
        .then(response => {
            this.messages = response.data;
        })
        .catch(function (error) {
            console.log(error);
        });
}

Or without using an arrow function:

created: function() {
    var that = this

    axios.get('/Chat/public/messages')
        .then(function (response) {
            that.messages = response.data;
        })
        .catch(function (error) {
            console.log(error);
        });
}
👤CD..

Leave a comment