0

//this is my code to get channel by unique name. It is not giving me any response

client.chat.services(serviceSid)
        .channels({uniqueName:'demo'})
        .fetch()
        .then(channel => console.log(channel));

// this is form sid of channel and it is working

client.chat.services(serviceSid)
        .channels('XXXXX')
        .fetch
        .then(channels=>  console.log(channel));

and the reponse is

{
  sid: 'CH...................b1e',
  accountSid: 'AC...................b71735f',
  serviceSid: 'IS..................caa8',
  friendlyName: 'demo',
  uniqueName: 'demo',
  attributes: '{}',
  type: 'public',
  dat2020-04-21T16:54:52.000Z,
  dateUpdated: 2020-04-21T16:54:52.000Z,
  createdBy: 'system',
  membersCount: 0,
  messagesCount: 0,
  url: }

in the doc this written in chaneel resource When fetching a Channel resource, the {Sid} value can be either the sid or the unique_name of the Channel resource to fetch. how will i retrive please answer .. i need to complete this project in 3 days ...

Vipul
  • 63
  • 1
  • 6
  • get channel by unique name code not giving me any response and you can see there is a channel with unqiuename demo . asd repononse is also there – Vipul Apr 21 '20 at 18:26
  • It's good that you comment out the sensitive part of the info. I remember that the whole thing was exposed when I first saw this post. – Algo7 Apr 21 '20 at 20:33

1 Answers1

1

https://www.twilio.com/docs/chat/rest/channel-resource#fetch-a-channel-resource I'm looking at these docs from twilio, and from their example, I'd try writing the code like this:

client.chat.services(serviceSid)
           .channels('demo')
           .fetch()
           .then(channel => console.log(channel));

Instead of passing an object, simply pass a string of the unique_name to get the channel you're looking for.