I'm making a chat Application with VueJS, but when an user is sending a message it should be saved in an array. But this array is not getting any data. Here is my code:
The variable:
data() {
    return {
        messages: [],
    }
},
And the method I'm using:
sendMessage() {
    socket.emit('chat message', {name: this.name, message: this.message});
    this.message = '';
    socket.on('get message', function (msg) {
        this.messages += {
             "name":"" + msg.name + "",
             "message":"" + msg.message + "",
        };
        console.log(this.messages);
    });
}
But when the this.messages += function should add a json object. But in the Vue Tab in the browser it still says it's an empty array. What is going wrong here?
