import SockJS from ‘sockjs-client‘; import Stomp from ‘stompjs‘; ws(url, subUrl) { return new Promise((resolve, reject) => { let socket = new SockJS(url) let stompClient = Stomp.over(socket) stompClient.connect({}, () => { stompClient.subscribe(subUrl, function (message) { try { resolve(message.body) } catch (err) { reject(err) } }) }) }) }