Closed 0xMochan closed 2 years ago
Thanks for you PR.
That's interesting problem.
I think there is a distinction needed between JupyterLite and pyscript. In JupyterLite the request is executed from a Worker. From the docs: "You cannot change the value of responseType in a synchronous XMLHttpRequest except when the request belongs to a Worker."
Did you test your solution with binary files? Like images or zip files?
Yea for sure, detecting if you are in a web-worker will be important.
I have not, def. a worthwhile test since I highly doubt json.loads
will work on those file formats. However, there's also the XMLHttpRequest.open_url
pyodide.http.open_url
which looks better suited for those types?
Ref: https://pyodide.org/en/stable/usage/api/python-api/http.html?highlight=fetch
I made some changes. Can you check version 0.0.8 ? The fix is based on your PR + https://stackoverflow.com/questions/44974003/recover-arraybuffer-from-xhr-responsetext
This makes it also possible to read data with pandas
.
According to the docs, setting
responseType
on theXMLHttpRequest
object sets the requirement that the call must be async.This results in the following exception in pyscript.