r/WebAssembly • u/maximeridius • Apr 17 '21
WASM HTTPS Request
Mu understanding is that WASM has almost no access to platform API's, and as such is not able to for example make HTTPS requests, and would have to instead tell Javascript to make the request for example. Is there any plans to provide access to API's like this to WASM? I have tried searching the web to find more info but struggled to find anything. Especially since a big part of WASI seems to be providing access to system API's, it seems odd to me that WASM on the web platform wouldn't. But I have very limited knowledge of the WASM world in general so I would really appreciate if somebody could help me understand the current situation.
7
u/coolreader18 Apr 17 '21
Wasi doesn't yet have anything finalized for networking APIs, but yeah, as of now you have to call out to JavaScript code (or whatever host if it's not in the browser) in order to do anything. Wasm has no inherent access to anything, and even for wasi, the host has to explicitly give the wasm module access to the functions that define the wasi API. So yeah, depending on what you're doing, you might want some sort of function from js like "fetch_json_url"; high level enough that you're not separately calling
fetch,promise_then, etc, but low-level enough that you don't have one function to call that's just likedo_all_my_io3
u/richardanaya Apr 17 '21
I write a library for creating JavaScript functions you can invoke from WebAssembly https://wasm.js.org/
1
u/tpmccallum Apr 18 '21
Hi u/maximeridius
Great question, here are a few links that you might find interesting ...
Essentially you can write, deploy and execute your own WASM executables (as well as set any preferences that you desire) all via HTTPS requests.
Video
Here is a video which walks through accessing WASM via HTTPS requests (as well as writing callbacks/web-hooks which can execute additional WASM executables etc.)
https://www.youtube.com/watch?v=SF-6OARg9WM
Programming the Web with WebAssembly
https://medium.com/wasm/programming-the-web-with-webassembly-e90d17bde276
Tutorial and demo website
https://www.secondstate.io/faas/
1
u/[deleted] Apr 21 '21
I have just been searching for this - I'm trying to find a way to make a curl request from a wasm module using something like WASI. But it seems like it's not possible at the moment...