If I create a raw string I can create the generic stream and then subscribe to a stream:
let ws = new WebSocket(`wss://stream.binance.com:9443/ws`);
....
ws.on("open", async () => {
ws.send(
JSON.stringify({
method: "SUBSCRIBE",
params: ["btcusdt@aggTrade"],
id: 1,
})
);
});
I want to do the same thing with a combined string, first create the generic stream and then subscribe to stream. I tried in different way but it doesn’t work:
let ws = new WebSocket(`wss://stream.binance.com:9443/stream/${listenKey}`);
let ws = new WebSocket(`wss://stream.binance.com:9443/stream?streams=/${listenKey}`);