Is there a way to effectively transfer data results received from socketIO to the Vue instance? Below is my current code implementation:
let socket = io();
let users;
socket.on('user-connected', (data) => {
users = data.count;
});
socket.on('user-disconnected', (data) => {
console.log(data.count);
});
new Vue({
el: '#playersCounter',
data: {
playerCounter: users
}
});
HTML:
<div class="d-flex justify-content-start" id="playersCounter">
<p class="onlinePlayersCounter">Online: {{playerCounter}}</p>
</div>
Currently, I am not receiving any errors but the data is not being displayed as expected.