Well big surprise, I’m running into a bunch of issues using the @dfinity/agent JS library in my RN app. For context, I’m using the library in iOS to call a canister running locally.
I’ve resolved a bunch of issues already—namely around polyfills for libraries not supported out-of-the-box in the RN JS engine—but I’m running into an issue I can’t easily resolve…
Basically, the read_state
HTTP endpoint is returning 200 but the body contains the text string undefined
instead of the Certificate. Code is here.
Here is what gets printed out when I console.log the Response object from the fetch() call:
{"type":"default","status":200,"ok":true,"statusText":"","headers":{"map":{"date":"Wed, 16 Jun 2021 22:24:48 GMT","access-control-allow-headers":"Accept, Authorization, Content-Type","content-length":"182","content-type":"application/cbor","access-control-allow-methods":"POST, GET","access-control-allow-origin":"*"}},"url":"http://localhost:8000/api/v2/canister/rrkah-fqaaa-aaaaa-aaaaq-cai/read_state","bodyUsed":false,"_bodyInit":{"_data":{"size":182,"offset":0,"blobId":"CB831679-886B-4AD7-A7A3-8735D070398F","type":"application/cbor","name":"read_state","__collector":{}}},"_bodyBlob":{"_data":{"size":182,"offset":0,"blobId":"CB831679-886B-4AD7-A7A3-8735D070398F","type":"application/cbor","name":"read_state","__collector":{}}}}
Does anyone know what’s going on? I’ve verified that the local canister I’m calling is running via dfx canister call ...
, which works fine. Maybe the @dfinity/agent JS library is making certain assumptions about the Fetch API that aren’t true in a mobile env?