moomoo
1
Hi guys, I am trying to connect to sencbird server but I got this error and cannot resolve it. the error is like below.
“Uncaught TypeError: Cannot read property ‘get’ of undefined”
The code I wrote is below.
<script>
sb = new SendBird({
appId: "xxyyzz"
});
sb.connect("x", "bb", function(user, error) { console.log(error); });
</script>
And also posting the sentry error report also.
How could I handle this error?
Thanks in advance
Hi Moomoo
Please refer to this official page and download the SDK.
- Create an HTML (remember you need to include Axios)
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width">
<title>JS Bin</title>
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
<script src="./sdk/SendBird.min.js"></script>
<script src="index.js"></script>
</head>
<body>
</body>
</html>
- Create your index.js
var sb = new SendBird({ appId: "..." });
sb.connect("test1", function(user, error) { console.log(user); });
Note: Try to use a userId (“test1” in my case) that exists in your Dashboard.
1 Like
moomoo
3
Thanks walter!
<script src="https://unpkg.com/axios/dist/axios.min.js"></script>
the code above fix my problem! thanks a lot