Web requests from web assemblies

Hi,
I was wondering if it was possible to make web requests from within web assemblies ?

I was looking at the Island source code and there is this

I was also looking at the documentation on the docs website and it has ServiceWorker

https://docs.elementscompiler.com/API/IslandRTL/Interfaces/ServiceWorker/

Is that the same as this ?

Where is a good place to look for examples ?

Thanks,
John

I’m afraid I have to leave that for Carlo or Diego on Monday :(. I don’t know much about this afea, myself

1 Like

No, it this one: XMLHttpRequest - Web APIs | MDN (mozilla.org)

usage: Using XMLHttpRequest - Web APIs | MDN (mozilla.org)

1 Like

Theo is right, that’s the best and easiest to use for doing web request.

1 Like

You can use as:

var l := Browser.NewXMLHttpRequest as dynamic;
l.addEventListener(“load”, new WebAssemblyDelegate(() → begin WebAssembly.Global.alert(l.responseText); end));
l.open(“GET”, “/urlToGet”);
l.send();

In future builds we will update the imported methods for XmlHttpRequest and will be easier to use (CC friendly, …)

3 Likes

We updated DOM translation of XMLHttpRequest, using next public release you can use it this way:

var la := Browser.NewXMLHttpRequest;
la.onload := new WebAssemblyDelegate(() → begin WebAssembly.Global.alert(la.responseText); WebAssembly.Global.alert(la.responseURL); end);
la.open(“GET”, “/urlToGet”);
la.send();

The big advantage is you have now code completion help for all XMLHttpRequest members.

3 Likes