i am trying to create a channel between 2 sendbird users using group channel. So far my implementation is
<script type="text/javascript">
function chatInit(){
var sb = new SendBird({
appId: 'my app id'
});
sb.connect('test user','access token of user', function(user, error) {
console.log(error);
});
var userIds = ['another user'];
var name ="name of channel";
sb.GroupChannel.createChannelWithUserIds(userIds, true, name ,'', '', function(channel, error) {
if (error) {
console.error(error);
return;
}
});
}
</script>
and i get following error on console
SendBird.min.js:6 Uncaught TypeError: Cannot read property 'userId' of null
at Function.GroupChannel.createChannelWithUserIds
am i missing something, please guide me through the process. any and all help will be appreciated.
The reason why you get that error response is because the connect has not run to completion as at the time the code
is run.
You need to add that add that block of code inside the callback function of sb.connect() like so: