websocket stream issue

node v12.11.1
version: 1.0.0
endpointsharetweet
const WebSocket = require('ws') const ws = new WebSocket('wss://api-pub.bitfinex.com/ws/2') const messageStream = WebSocket.createWebSocketStream(ws, { encoding: 'utf8' }) ws.once('open', function open() { ws.send(JSON.stringify({ event: 'subscribe', channel: 'book', len: 100, prec: 'P0', freq: 'F0', symbol: `tBTCUSD` })) }) async function run() { for await (let message of messageStream) { console.log('string msg', message) console.log('parsed msg', JSON.parse(message)) } } await run()
Loading…

no comments

    sign in to comment