Skip to content

Latest commit

 

History

History
95 lines (61 loc) · 1.69 KB

File metadata and controls

95 lines (61 loc) · 1.69 KB

Use RestSharp library to send HTTP(s) requests from inside WASM in Node.js, Bun, and Deno

Instructions for this devcontainer

Tested with .Net SDK version 9.0.200, Bun 1.2.4, Deno 2.2.2, Node.js 22.14.0, RestSharp v112.1.0.

Preparation

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

Building

  1. cd into the folder of this example:
cd browser-and-node-RestSharp/node
  1. Create new .Net project using wasmconsole template:
dotnet new wasmconsole -n NodeProject
  1. Replace generated HelloWorld-like Program.cs and main.mjs with HTTP-enabled ones:
cp ../Program.cs ./NodeProject/
cp ../main.js ./NodeProject/main.mjs
  1. cd into the folder of the new .Net project to use it:
cd NodeProject
  1. Install RestSharp library as dependency:
dotnet add package RestSharp
  1. Compile the example:
dotnet build

Test with Node.js

  1. Run the configuration:
dotnet run

Or, alternatively, the same by directly using node command:

node bin/Debug/net9.0/browser-wasm/AppBundle/main.mjs

Test with Bun

  1. Install Bun:
curl -fsSL https://bun.sh/install | bash
  1. Run with Bun:
~/.bun/bin/bun bin/Debug/net9.0/browser-wasm/AppBundle/main.mjs

Test with Deno

  1. Install Deno:
curl -fsSL https://deno.land/install.sh | bash -s -- --yes
  1. Run with Deno:
~/.deno/bin/deno run --allow-read --allow-net --unstable-bare-node-builtins bin/Debug/net9.0/browser-wasm/AppBundle/main.mjs

Finish

Perform your own experiments if desired.