How to check if a chat channel exists? (by id)

[React] [SDK Docs]

I am using the following block of code from the docs to retrieve a channel:

const liveChannel = ChannelRepository.getChannel('channelId');

liveChannel.once('dataUpdated', data => {
  // 
});

As far as I know, this provides the LiveChannel object for the given channel Id. But it throws an error if a channel doesn’t exist by that channel Id provided.

How do I check if a channel exists by an id? My intention is to create a channel by a certain Id if it doesn’t already exist.

Would I be right to take the error handling as the method to find out if the channel doesn’t exist? Using this atm:

liveChannel.once('dataError', error =>
{
      //
}

Hi @abhishek ,

That error expected behaviour, you can use it as indication that the channel id doesn’t exist. Yes, you’re correct to use that.

Amity Support