Skip to content

Latest commit

 

History

History
76 lines (48 loc) · 1.31 KB

README.md

File metadata and controls

76 lines (48 loc) · 1.31 KB

Use Wasmoon to send HTTP(s) requests from inside WASM

This example uses binary build of Wasmoon

Instructions for this devcontainer

Preparation

  1. Open this repo in devcontainer, e.g. using Github Codespaces. Type or copy/paste following commands to devcontainer's terminal.

  2. cd into this example's folder:

cd browser-and-node
  1. Install Wasmoon using npm:
npm install wasmoon

Test with Node.js

node src/httpget.mjs

Test with Deno

Optionally you can also test with Deno.

  1. Install Deno:
curl -fsSL https://deno.land/x/install/install.sh | sh
  1. Perform the test:
~/.deno/bin/deno run --allow-read --allow-net src/httpget.mjs 

Test with browser

  1. Install webpack:
npm install webpack-cli
  1. Run webpack to build a web bundle:
npx webpack

This creates a dist folder with 100k JS bundle main.js inside it.

  1. Run simple HTTP server to temporarily publish project to Web:
python3 -m http.server

Codespace will show you "Open in Browser" button. Just click that button or obtain web address from "Forwarded Ports" tab.

  1. As index.html loaded into browser, refer to browser developer console to see the results.

Finish

Perform your own experiments if desired.