Saturday 18 March 2017

socket.io and vue.js fetching data

I am trying to fetching the data of vue.js using this

fetchData: function () {
                socket.emit('getAllSongs')
                socket.on('allSongs',function(data) {
                    this.songs = data
                });

          }

FetchData is called when the vue app is created

created: function () {
            this.fetchData();
        }

But when I try to call the variable songs outside socket.on it stills empty.

What could I do?



via Rafael Andrade

No comments:

Post a Comment