Open halilulker opened 1 year ago
Hi,
There are a few problems with your code:
Promise
s (await
) and callbacks (the function you send as a second argument). See here for more details.('PUBSUB CHANNELS', [])
means that the 'PUBSUB CHANNELS'
will be ignored, and only the empty array and the callback function will be passed to the sendCommand
function:
function func() {
console.log(arguments);
}
func((1, 2), 3); // This will log [2, 3] and ignore 1
3. You are sending `PUBSUB CHANNELS` as one argument instead of two (it should be `['PUBSUB', 'CHANNELS']`, not `['PUBSUB CHANNELS']`).
If you want to use the `.sendCommand` command to use the commands "as-is" do:
```javascript
const result = await redis.sendCommand(['PUBSUB', 'CHANNELS']);
Or, if you want to use a "type-safe" more "JavaScript friendly" API (which is probably what your are looking for):
const result = await client.PUBSUB_CHANNELS();
// or
const result = await client.pubSubChannels();
Description
I try like this but no message in console. When I try redis-cli console its working but I dont find right syntax in nodejs.