py_mini_racer._objects.JSPromiseError: JavaScript rejected promise with reason: ReferenceError: atob is not defined
Steps to reproduce
I have this line of code in my JavaScript " return new Uint8Array(atob(tsv).split("").map(n => n.charCodeAt(0))) "causing an error async def get_xcvi(): ctx = MiniRacer() ctx.eval(js_code) promise = ctx.eval("new Promise((res, rej) => res(get_xct()))") res = await promise print(res)
Expected behavior
Tell us what should happen
Actual behavior
Traceback (most recent call last):
File "J:\code\nbBotTest\nbBotTest\moduleTest\x_spider.py", line 116, in
System configuration
PyMiniRacer 0.12.4:
Python 312:
Hi!
atob is a web Api (defined on the window object), not a JavaScript API, so PyMiniRacer and V8 don't define it.
You could try providing your own atob through wrap_py_function, although it would need to be async (so you'd need an extra await or two in your code).
An alternative would be to contribute it to PyMiniRacer as C++ code. Or, one day, [this proposal](https://tc39.es/proposal-arraybuffer-base64/spec/#sec-uint8array.frombase64] to add Uint8Array.fromBase64() to JavaScript might eventually land and get picked up by V8!