Issue type
Brief description
The JS example available at the documentation site is designed to work with Node.js. However, if we make some little changes, it will also work out-of-the-box on the browser after we remove the require line:
- const ws = require('ws')
+ const WebSocket = require('ws')
- const w = new ws('wss://api-pub.bitfinex.com/ws/2')
+ const ws = new WebSocket('wss://api-pub.bitfinex.com/ws/2')
- w.on('message', (msg) => console.log(msg))
+ ws.onmessage = (msg) => console.log(msg)
- let msg = JSON.stringify({
+ const msg = JSON.stringify({
event: 'subscribe',
channel: 'ticker',
symbol: 'tBTCUSD'
})
- w.on('open', () => w.send(msg))
+ ws.onopen = () => ws.send(msg)
Additional Notes:
I couldn't find the mentioned documentation site here at GitHub, so that I could send a PR proposing the changes.
Issue type
Brief description
The JS example available at the documentation site is designed to work with Node.js. However, if we make some little changes, it will also work out-of-the-box on the browser after we remove the
requireline:Additional Notes:
I couldn't find the mentioned documentation site here at GitHub, so that I could send a PR proposing the changes.