'How to limit the message stream interval of a web socket I connected to
I dont think it is necessary to post my code here, but incase it is I have it below.
I am connected to coinbases websocket and trying to pull prices on coins but the message stream feeds me data many times per second, but I am looking to pull price data about once a minute.
Can anyone help me understand how to limit a message stream using the WS node package?
const stream = new WebSocket('wss://ws-feed.exchange.coinbase.com')
stream.on('open', () => {
stream.send(JSON.stringify({
"type": "subscribe",
"product_ids": [
"BTC-USD"
],
"channels": [
{
"name": "ticker",
"product_ids": [
"BTC-USD"
]
}
]
}))
})
stream.on('message', (data) => {
console.log('received: ', JSON.parse(data))
})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
