Konubinix' opinionated web of thoughts

Simulate Http Server Using Service Workers


simulate http server using service workers

Very practical when providing wasm functionalities while keeping an homogeneous development environment, using http (fetch) communication everywhere.

Open this page and enable the inspector (F12) to see how fetching behaves.

// fetching a real document
r = await fetch("index.html")
await r.text()

// fetching some data that actually is generated by something like a wasm program
r = await fetch("dummy/something")
await r.json()


See how I can fetch a page normally but still catch dummy pages and return my own kind of responses?