-7

I used websocket to get a channel. Using the condition for the 'event' you need to output to the console the id and the name of the pair.

let ChanIds = {};
w.on('message',(msg) => {
  console.log(msg);
        if (msg.event) {
        }
});
{"event":"subscribed","channel":"ticker","chanId":4,"symbol":"tBTCUSD","pair":"BTCUSD"}"
 let ChanIds = { 4 : tBTCUSD };
  

Need to give a key to an object

Evaa
  • 283
  • 1
  • 2
  • 15
  • `let chanIds = {}` then `chanIds[firstObj.chanId] = firstObj.symbol` – A. Bandtock Apr 04 '18 at 11:16
  • 1
    you can try your question also here: https://ru.stackoverflow.com/. Maybe it's easier to express yourself. – Edwin Apr 04 '18 at 11:17
  • Possible duplicate of [How to get all properties values of a Javascript Object (without knowing the keys)?](https://stackoverflow.com/questions/7306669/how-to-get-all-properties-values-of-a-javascript-object-without-knowing-the-key) – Nikola Lukic Apr 04 '18 at 11:27
  • can not get key.must use w.on('message', (msg) => { console.log('log--', msg); if (msg.event) { } }); – Лена Фролова Apr 04 '18 at 11:46

1 Answers1

0

let chanIds[someObject.chanId] = someObject.symbol