I'm looking at the documentation on Coinbase's Github for the GDAX API and trying to subscribe to the heartbeat channel, but keep being returned with the below error when I utilize this code:
var websocket = new Gdax.WebsocketClient(
['BTC-USD'],
'wss://ws-feed.gdax.com',
{
key: API_KEY,
secret: API_SECRET,
passphrase: API_PASSPHRASE,
},
{ heartbeat: true }
)
webSocket.on('message', data => {
console.log(data);
});
Error:
{
type: 'error',
message: 'Failed to subscribe',
reason: 'You need to specify at least one product ID for channel heartbeat'
}
Be sure to include
"product_ids" : ["BTC-GBP"]
as a field in the Json request.So something like this should work (from their API docs)
See here https://docs.gdax.com/#subscribe