Closed b1f6c1c4 closed 1 year ago
XMLHttpRequest is used only in long polling. Long polling is a fallback mechanism when websockets are not available. Given that you fully control your node environment, you can always include a websocket provider and consequently long polling won't ever be needed. Have you provided a websocket implementation as suggested? https://github.com/tinode/tinode-js/blob/master/README.md#node-js-compatibility
Actually XMLHttpRequest is also used in file uploads, so I suppose it needs to be polyfilled too. And URL.createObjectUrl() needs to be polyfilled. I'll make the changes in the SDK.
OK, I've updated the SDK to allow polyfilling of XMLHttpRequest
too and added instructions how to do it.
The URL.createObjectURL
is still not polyfilled and I don't have time to work on it right now. We do not use this code under Node. You are welcome to send a pull request.
A full replacement is great, but a workaround would be sufficient too. Maybe an alternative way of downloading when createObjectURL is not available. Or maybe have createObjectURL return a data URL https://developer.mozilla.org/en-US/docs/Web/HTTP/Basics_of_HTTP/Data_URIs
The original issue with XMLHttpRequest
has been resolved. The createObjectURL
was added in Node v16.7.0.
Let's close this issue as it is no longer clear what's exactly missing. Please file a new issue if something is still broken when running in Node environment.
This paragraph causes the following error in nodejs:
Error: XMLHttpRequest is not defined (503)
I recommend using axios for this.