Hello! In the component I want to implement the reception of data on the web socket, the connection is established, but inside onopen there is no send send https://jsfiddle.net/cergey251/tchxpbv4/ .
var app = new Vue({ el: '#app', data: { socket: null, message: 'Hello Vue!' }, created() { this.socket = new WebSocket('wss://api2.poloniex.com/'); this.socket.onopen = function() { this.send(JSON.stringify({ command: 'subscribe', channel: 1002 })); } } }) The similar code works on pure js, the data correctly come https://jsfiddle.net/cergey251/okxw3dtq/ .
var socket = new WebSocket('wss://api2.poloniex.com/'); socket.onopen = function() { socket.send(JSON.stringify({ command: 'subscribe', channel: 1002 })); socket.send(JSON.stringify({ command: 'subscribe', channel: 'USDT_XRP' })); }; socket.onmessage = function(event) { var msg = JSON.parse(event.data); console.log(msg); }; What could be the problem? I would be very grateful for the help)