global atob btoa not available in JavaScriptCore and react-native
Closed this issue ยท 4 comments
sjmueller commented
Getting this exception when running a react-native project on device:
global.atob is not a function
Most likely due to this line:
socketcluster-client/lib/scsocket.js
Line 352 in 1b2cc0b
Perhaps the solution is to use a polyfill like https://github.com/mathiasbynens/base64 to supplement these methods when running socketcluster-client
in a more restricted runtime like JavaScriptCore.
sjmueller commented
Verified works with base-64
(don't forget the dash!)
For react-native googlers, npm i --save base-64
, then add this somewhere in your codebase and make sure it runs before socketcluster-client
is referenced:
if (!global.atob) {
global.atob = require('base-64').decode;
}
jondubois commented
@sjmueller Ok, that should be fixed in v4.1.6
.
sjmueller commented
Confirmed! Thanks @jondubois!
dilipkumar2k6 commented
Thanks @sjmueller, it worked for me ๐