"XMLHttpRequest is not defined" error in sendbird-desk npm package


Running the following in a serverside nodejs application. I get connected to the API but authentication fails!

-------------- Code Example --------------
var sb = new SendBird({appId: process.env.SENDBIRD_APP_ID});
sb.connect(sbuser.sendbirduserid, sbuser.sendbirdaccesstoken, function(user, error) {
// the user object is correct
SendBirdDesk.authenticate(sbuser.sendbirduserid, sbuser.sendbirdaccesstoken, (user, error) => {
// Here error = “XMLHttpRequest is not defined”

-------------- Full Error --------------
stack: “ReferenceError: XMLHttpRequest is not defined
at /home/ec2-user/environment/user/node_modules/sendbird-desk/SendBird.Desk.min.js:6:6849
at new Promise ()
at x (/home/ec2-user/environment/user/node_modules/sendbird-desk/SendBird.Desk.min.js:6:6750)
at G (/home/ec2-user/environment/user/node_modules/sendbird-desk/SendBird.Desk.min.js:6:10937)
at process._tickCallback (internal/process/next_tick.js:68:7)”
message: “XMLHttpRequest is not defined”

It seems the SDK is made for browser run javascript only but that’s not what the documentation says!
Spent a whole day trying to hammer at this from different angles, but can’t get it to work!



All of our JavaScript SDKs are designed to be utilized in the web, and thus may not function correctly in server side nodejs.


1 Like

Ok, thanks for the quick reply.