HTTP Request from inside WASM implemented in Crystal-lang

This example uses lbguilherme/crystal-js library.

See the output in browser developer console.

Actual code:


req = XMLHttpRequest.new
req.open("GET", "https://httpbin.org/anything", false)
req.send
JS.console.log req.response_text

Info

Warning This example employs XMLHTTPRequest in synchronous form. Consider making such calls only from inside of Web Workers to avoid UI freezes.

And this example: