Hi @joshuef, I’m playing around with the safe api on SAFE Browser, pretty cool work. I manage to authenticate and create a file but when I try to get it back I get the following error:
Uncaught (in promise) Error: Unexpected token a in JSON at position 0(…)
My call looks like this:
window.safeNFS.getFile(token, "test");
Any idea?
EDIT: Is there a debug mode to see the content of the request that goes to the launcher?
So polyfill.js is to get the same window.safexxx api inside another browser like chrome right? Is that how you use it, not directly inside the Safe Browser?
No, polyfill.js is for SAFE Browser - it allows you to run locally, either as file:// (not tried) or using a local web server (e.g. as localhost:8000).
Also, you can set a breakpoint in your call (above) and step in to see exactly what is going to Launcher. Did this last night.
You’ll need to turn off CORS checks to work locally though, within SAFE Beaker (toolbar button / menu item).
Oh wow, ok I installed safe-js through npm and it generated a gazillion files! Damn, lol, I’m a bit surprised, polyfill itself is six thousands lines long. Is that all necessary? I guess for development that could work.
i really don’t like using node/browser hydrid code, these things are a visual abomination eheh. Anyway enough rant, thanks for the info.
I don’t think the problem is with the parameter, isPathShared has a value by default so it’s optional. The token I use is the one from authorise and the filepath is just the same name of the file I created before. Seems to be an internal error. I’ll dive a little deeper.
EDIT: Oh, maybe I’m not using the correct version of the launcher. I’ll have to check that out later.
Do you see the launcher logs as well? Does it receive a request? And does that succeed or fail on the launcher?
It could be that the launcher is returning an error, and that’s causing safe-js errors. (Improving safe-js error logging it on the list! sorry, I’m aware it’s a bit of a pain right now).